CS FundamentalsModerateGATE CS · SQL

Table Staff(id, name, dept, pay, boss) rows: (1, 'Anu', 'Ops', 40, NULL), (2, 'Bala', 'Ops', 55, 1), (3, 'Chitra', 'Tech', 70, 1), (4, 'Dev', 'Tech', NULL, 3), (5, 'Esha', NULL, 35, 3), (6, 'Farid', 'Tech', 70, 2). What does this query return?

Table Staff(id, name, dept, pay, boss) rows: (1, 'Anu', 'Ops', 40, NULL), (2, 'Bala', 'Ops', 55, 1), (3, 'Chitra', 'Tech', 70, 1), (4, 'Dev', 'Tech', NULL, 3), (5, 'Esha', NULL, 35, 3), (6, 'Farid', 'Tech', 70, 2). What does this query return?
SELECT COUNT(*), SUM(pay), MAX(pay)
FROM Staff
WHERE pay > 100;
  1. A. 0, 0, NULL
  2. B. No rows (empty result)
  3. C. 0, NULL, NULL
  4. D. 0, 0, 0

Correct answer: C. 0, NULL, NULL

No row has pay > 100. COUNT of an empty set is 0, but SUM and MAX of an empty set are NULL, not 0; the single summary row is still returned.

More DBMS and SQL questions

Exams that ask this topic