CS FundamentalsHardGATE CS · Amazon/Microsoft SDE MCQ

Table T has 7 rows. What does SELECT COUNT(*) FROM T HAVING COUNT(*) > 10; return? (Standard SQL; SQLite accepts HAVING without GROUP BY from 3.39.)

  1. A. One row containing 0
  2. B. One row containing 7
  3. C. An error, since HAVING needs GROUP BY
  4. D. No rows at all

Correct answer: D. No rows at all

Without GROUP BY the whole table is a single group of 7 rows; HAVING tests that group, 7 > 10 is false, so the group and hence the only output row is removed. The result is empty, not 0.

More DBMS and SQL questions

Exams that ask this topic