CS FundamentalsHardTCS Digital · Infosys SP · GATE CS
Table Product(pid, cat, price) rows: (1, 'X', 10), (2, 'X', 20), (3, 'Y', 20), (4, NULL, 30), (5, 'Y', NULL), (6, 'Z', 5). How many rows does this query return?
Table Product(pid, cat, price) rows: (1, 'X', 10), (2, 'X', 20), (3, 'Y', 20), (4, NULL, 30), (5, 'Y', NULL), (6, 'Z', 5).
How many rows does this query return?
SELECT cat, COUNT(*) FROM Product GROUP BY cat HAVING AVG(price) > 12;
- A. 3
- B. 2
- C. 1
- D. 4
Correct answer: A. 3
Groups: X avg 15, Y avg 20 (NULL ignored), NULL-category group avg 30, Z avg 5. Three groups pass, including the NULL group.
More DBMS and SQL questions
- Table Staff(id, name, dept, pay, boss) rows: (1, 'Anu', 'Ops', 40, NULL), (2, 'Bala', 'Ops', 55, 1), (3, 'Chitra', 'Tech', 70, 1), (4…
- Table Staff(id, name, dept, pay, boss) rows: (1, 'Anu', 'Ops', 40, NULL), (2, 'Bala', 'Ops', 55, 1), (3, 'Chitra', 'Tech', 70, 1), (4…
- 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}⁺?