Window Functions · SQL SQL

Which ranking window function assigns the same rank to identical values with no gaps in ranking sequence, meaning if two rows share rank 1, the next…

Practice question from Window Functions (SQL SQL), with the correct answer and a step-by-step solution.

medium · MCQ · Q-06BBB0

Which ranking window function assigns the same rank to identical values with no gaps in ranking sequence, meaning if two rows share rank 1, the next rank is 2?

  1. A.ROW_NUMBER()
  2. B.RANK()
  3. C.DENSE_RANK()Correct answer
  4. D.NTILE()

Solution

DENSE_RANK() assigns consecutive ranks to rows with duplicate values without leaving gaps in the ranking sequence. In contrast, RANK() leaves gaps (e.g., 1, 1, 3), and ROW_NUMBER() assigns unique sequential numbers.

More from Window Functions

All of Window Functions

Practise more SQL

Sign up free for adaptive practice on this chapter, with instant feedback and hints on every question.

Start practising free

Free to start · No credit card needed