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). What 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).
What does this query return?
SELECT COUNT(*) FROM Product p
WHERE price > (SELECT AVG(price) FROM Product q
WHERE q.cat = p.cat);- A. 2
- B. 1
- C. 3
- D. 0
Correct answer: B. 1
X average is 15, so pid 2 (20) qualifies. Y's average is 20 and 20 > 20 is false; Z has one row; the NULL-cat row's subquery matches nothing. Only 1 row.
More DBMS and SQL questions
- R(A, B, C, D, E) with functional dependencies E → BC, D → B is decomposed into R1(A, B, D), R2(C, D), R3(B, C, E). Which statement is…
- A B+ tree index uses 1024-byte blocks, 12-byte search keys, 10-byte block pointers and 6-byte record (data) pointers. Each leaf also keeps…
- Which statement about a UNIQUE constraint versus a PRIMARY KEY in standard SQL is correct?
- Consider the schedule R1(B), W3(B), W3(A), R2(B), W2(A), R1(A), W1(A). Which statement is correct?
- Extendible hashing uses the LOWEST-order bits of a key's binary value, bucket capacity 2, and starts with global depth 0 and one empty…
- Table Takes(sid, cid, marks) rows: (1, 'C1', 80), (1, 'C2', NULL), (2, 'C1', 65), (3, 'C2', 90), (3, 'C3', 75), (5, 'C1', 50). What does…