CS FundamentalsHardGATE CS (PYQ pattern)

Table AA(x, y): (1,1), (1,2), (2,2), (2,NULL), (3,NULL), (NULL,3). How many groups does SELECT x FROM AA GROUP BY x HAVING COUNT(y) < COUNT(*) return?

  1. A. 1
  2. B. 3
  3. C. 4
  4. D. 2

Correct answer: D. 2

COUNT(y) < COUNT(*) means the group contains a NULL y: x = 2 (one NULL) and x = 3 (all NULL). x = 1 has none and the NULL-x group has y = 3 only. So 2 groups.

More DBMS and SQL questions

Exams that ask this topic