CS FundamentalsVery hardGATE CS (PYQ pattern)
Table M(g, v): (x,10), (x,NULL), (x,20), (y,NULL), (y,NULL), (z,30). How many groups does SELECT g FROM M GROUP BY g HAVING COUNT(*) > COUNT(v) return, and what does SELECT SUM(v) FROM M WHERE g = 'y' return?
- A. 2 groups; SUM is 0
- B. 1 group; SUM is NULL
- C. 2 groups; SUM is NULL
- D. 3 groups; SUM is NULL
Correct answer: C. 2 groups; SUM is NULL
COUNT(*) counts rows and COUNT(v) skips NULLs: x has 3 > 2, y has 2 > 0, z has 1 = 1, so x and y qualify (2 groups). SUM over only NULL values is NULL, not 0.
More DBMS and SQL questions
- O(oid, c): (1,100), (2,100), (3,200), (4,NULL). I(oid, p, q): (1,5,2), (1,6,1), (2,5,3), (3,7,1), (3,7,1), (9,1,1). C(c, n): (100,u)…
- Transaction T1 executes R1(A), W1(A), R1(B) and T2 executes W2(A), R2(B), W2(B), each in the stated order (no commits modelled). Among all…
- Consider the schedule R2(X), W1(X), W2(X), W2(Y), C2, R1(Y), C1, W3(X), R3(X), C3 (Ci is the commit of Ti). Which is the strongest…
- Schedule S: R1(X), W2(X), W2(Y), W1(Y), W3(X), W3(Y), R3(Y). Which statement is correct?
- Basic timestamp ordering with TS(T1) < TS(T2) < TS(T3). A transaction aborts when it violates the rules, and once aborted its later…
- A system uses immediate database modification with a log. Log (oldest first): <T1 start>, <T1,A,10,20>, <T2 start>, <T2,B,5,6>, <T1…