CS FundamentalsModerateProduct-company placement

Player(pid, team, runs) has rows (1, 'A', 50), (2, 'A', 70), (3, 'A', 70), (4, 'B', 40), (5, 'B', NULL), (6, 'B', 90), (7, 'C', NULL). For player 1, what are RANK() OVER (ORDER BY runs DESC NULLS LAST) and DENSE_RANK() OVER (ORDER BY runs DESC NULLS LAST)?

  1. A. 3 and 3
  2. B. 4 and 4
  3. C. 4 and 3
  4. D. 3 and 2

Correct answer: C. 4 and 3

Ordered: 90, 70, 70, 50, 40, NULL, NULL. RANK leaves a gap after the tie (1, 2, 2, 4) so 50 gets 4; DENSE_RANK has no gaps (1, 2, 2, 3) so 50 gets 3. 3 and 2 counts the higher rows but forgets to add 1.

More DBMS and SQL questions

Exams that ask this topic