CS FundamentalsVery hardGATE CS · SQL
Table Score(name, pts) rows: ('a', 90), ('b', 85), ('c', 90), ('d', 70), ('e', 85), ('f', 60). What does this query return?
Table Score(name, pts) rows: ('a', 90), ('b', 85), ('c', 90), ('d', 70), ('e', 85), ('f', 60).
What does this query return?
SELECT name FROM Score s
WHERE 2 = (SELECT COUNT(DISTINCT pts) FROM Score t
WHERE t.pts > s.pts)
ORDER BY name;- A. a, c
- B. f
- C. b, e
- D. d
Correct answer: D. d
A row qualifies when exactly two DISTINCT scores are higher than it. Above 70 are only 90 and 85, so d (the third-highest distinct score) is returned. With COUNT(*) instead, b and e (two 90s above 85) would be returned.
More DBMS and SQL questions
- The system crashes after the last record of this log (immediate database modification; <Ti, X> denotes an update with old and new values…
- Classify the schedule R3(A), W2(A), W3(B), R2(B), W3(A), W1(A), R1(B), W1(B).
- A multilevel index is built over a first level of 40,000 index entries; every index block holds 34 entries (fan-out 34), and levels are…
- Why does a B+ tree usually have a smaller height than a B-tree built on the same key with the same block size?
- A multilevel index is built over a first level of 1,000,000 index entries; every index block holds 100 entries (fan-out 100), and levels…
- Table Acct(no, branch, bal) rows: (101, 'Agra', 500), (102, 'Agra', 1500), (103, 'Bhopal', 700), (104, 'Bhopal', 700), (105, 'Cuttack'…