CS FundamentalsHardGATE 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 COUNT(*) FROM Score a JOIN Score b ON a.pts < b.pts;
  1. A. 15
  2. B. 10
  3. C. 13
  4. D. 12

Correct answer: C. 13

Scores: 90, 90, 85, 85, 70, 60. 60 is below 5 others, 70 below 4, each 85 below 2 (the 90s), and each 90 below none: 5 + 4 + 2 + 2 = 13. Equal scores form no pair.

More DBMS and SQL questions

Exams that ask this topic