Machine-translated by Google. Questions are authored in English.
Top

Discussion

The qualifier DISTINCT must be used in an SQL statement when we want to eliminate duplicate rows.

  • A.True
  • B.False

Answer: A

Correct answer: True

A plain SELECT returns every row that matches, duplicates included, because SQL tables are multisets rather than true sets. To collapse repeats, DISTINCT must be stated explicitly.

Two details are worth knowing. It applies to the whole selected row, so SELECT DISTINCT city, state removes only rows where both values repeat. And it is not free: the engine must sort or hash the result to find the duplicates, so on a large result set the cost is real.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.