CS FundamentalsModerateGATE CS (PYQ pattern)
GB(id, v): (1,5), (2,12), (3,18), (4,25), (5,31), (6,39), (7,NULL). The query SELECT v / 10, COUNT(*) FROM GB GROUP BY v / 10 uses integer division. How many groups (rows) does it return, and how many of them have COUNT(*) >= 2?
- A. 4 groups, 2 with at least 2 rows
- B. 5 groups, 2 with at least 2 rows
- C. 5 groups, 3 with at least 2 rows
- D. 6 groups, 1 with at least 2 rows
Correct answer: B. 5 groups, 2 with at least 2 rows
v / 10 gives 0 (v = 5), 1 (12, 18), 2 (25), 3 (31, 39) and NULL (the NULL row forms its own group). That is 5 groups; groups 1 and 3 have two rows each.
More DBMS and SQL questions
- Three transactions each execute R(A) followed by W(A) on the same item A. Among all interleavings of the six operations (each…
- T1: R(A), W(A), R(B) and T2: R(B), W(B), R(A), each in that order. Of the C(6,3) = 20 interleavings, how many are conflict-serializable?
- T1: W(A) W(B) and T2: W(B) W(A) run under strict 2PL (exclusive locks held until the transaction ends; a schedule counts only if no…
- Table T(x) holds the values 1, 2, 3, NULL and table U(y) holds 2, NULL. Let Q1 = SELECT COUNT() FROM T WHERE x NOT IN (SELECT y FROM U)…
- DEPT(d, name) has rows (10,A), (20,B), (30,C), (40,D) and EMP(id, dept) has 3 employees in dept 10, 2 in dept 20, 1 in dept 30 and none in…
- EMP has salaries 300, 200, 200, 200, 150, 100 for six employees. Let QR select employees whose RANK() OVER (ORDER BY sal DESC) equals 3…