Values 100, 100, 90 are ranked in descending order. What do RANK, DENSE_RANK and ROW_NUMBER produce?
A
1,2,3 for all three functions, because every row receives a distinct sequential position
B
1,1,2 for RANK and 1,1,3 for DENSE_RANK, with 1,2,3 for ROW_NUMBER in the very same single query
C
1,1,3 for RANK; 1,1,2 for DENSE_RANK; and 1,2,3 for ROW_NUMBER with an arbitrary tie order
Correct answer
D
1,1,3 for all three, since ties always skip a position whatever function is used
Correct answer
C. 1,1,3 for RANK; 1,1,2 for DENSE_RANK; and 1,2,3 for ROW_NUMBER with an arbitrary tie order
15 views
⚔️
Challenge a friend on SQL for Data Analysis
Same MCQs, timed, live leaderboard. Send the link on WhatsApp – no sign-up needed.
Create challenge
Explanation
Ranking functions differ only in tie handling: RANK leaves a gap after a tie, DENSE_RANK does not, and ROW_NUMBER assigns consecutive integers arbitrarily among tied rows. Using ROW_NUMBER for deduplication is therefore non-deterministic unless the ORDER BY is a total order. Adding a unique tiebreaker column is the standard fix.
Reference
Asked in: NTS, PPSC IT, Interviews
Doubts & discussionNot sure why the answer is C? Ask here and get an explanation.
Ask a doubt about this MCQ
‹ Previous MCQ In SUM(x) OVER (ORDER BY d), the default window frame uses RANGE. What practical difference does that make compared with an explicit ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW? Next MCQ › A LEFT JOIN carries the right-table condition b.status = 'active' in the WHERE clause instead of the ON clause. What is the effect?