CS FundamentalsHardGATE CS (PYQ pattern)

Tables T(x): 1, 2, 3 and U(y) is EMPTY. In standard SQL, what does SELECT COUNT(*) FROM T WHERE x > ALL (SELECT y FROM U) return, and what does SELECT COUNT(*) FROM T WHERE x > ANY (SELECT y FROM U) return?

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

Correct answer: C. 3 and 0

x > ALL over an empty set is vacuously TRUE (every row qualifies), while x > ANY over an empty set is FALSE (there is no y to exceed).

More DBMS and SQL questions

Exams that ask this topic