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;
- A. 0, 0, NULL
- B. No rows (empty result)
- C. 0, NULL, NULL
- 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
- Consider the schedule W2(A), R1(A), R2(A), W3(A), R3(A), R1(C). Which statement is correct?
- TS(T1) = 25, TS(T2) = 5, TS(T3) = 30; all read/write timestamps start at 0. Under basic timestamp ordering (no Thomas write rule), which…
- R(A, B, C, D, E) has functional dependencies DE → B, C → E, D → AC. What is the highest normal form R satisfies?
- R(A, B, C, D, E, F) has functional dependencies C → B, F → C, DF → B, B → F, A → F. What is the closure {AE}⁺?
- R(A, B, C, D, E) with functional dependencies B → E, CE → B, C → E, E → C is decomposed into R1(A, C, E), R2(A, B, D), R3(B, C). Which…
- Classify the schedule W1(B), R3(A), W2(B), R2(B), W1(A), C2, C1, W3(B), C3 (Ci = commit of Ti) by the strongest property it satisfies.