CS FundamentalsHardGATE CS

M(s) holds the scores 90, 85, 85, 80, 80, 80, 70, 70, 60. What is the sum over all nine rows of (RANK() OVER (ORDER BY s DESC) - DENSE_RANK() OVER (ORDER BY s DESC))?

  1. A. 10
  2. B. 13
  3. C. 16
  4. D. 40

Correct answer: B. 13

RANK leaves gaps after ties while DENSE_RANK does not: ranks are 1, 2, 2, 4, 4, 4, 7, 7, 9 and dense ranks 1, 2, 2, 3, 3, 3, 4, 4, 5, so the differences sum to 13.

More DBMS and SQL questions

Exams that ask this topic