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

Discussion

The SQL statement: SELECT Name, COUNT(*) FROM NAME_TABLE; counts the number of name rows and displays this total in a table with a single row and a single column.

  • A.True
  • B.False

Answer: B

Correct answer: False

The statement mixes an ungrouped column with an aggregate. Name has one value per row while COUNT(*) has one value for the whole table, and there is no rule for pairing them.

Standard SQL rejects the query, and so do most engines in their default configuration. Either drop the column, giving SELECT COUNT(*) FROM NAME_TABLE and a single row, or add GROUP BY Name, giving one row per distinct name with its own count - but not the single row the statement describes.

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

Post your comment

Please log in or register to post a comment.