Back to Practice
#0328
Dense Rank Scores
MediumSQL24 min20 XP
Problem
Return player, score, and dense_rank ordered by score descending.
Why This Matters
SQL interviews usually test whether you can turn a business question into the right rows, grouping level, join type, and edge-case behavior.
Schema
scores(player TEXT, score INTEGER)
Examples
Example 1
InputA and B tie at 100
Outputboth rank 1, C rank 2
DENSE_RANK does not skip rank 2 after a tie.
Constraints
- Return only the requested columns.
- Use deterministic ORDER BY when multiple rows are returned.
- Assume SQLite-compatible SQL unless the prompt states otherwise.
CodeSQL
Visible browser tests run here when available.
Testcases1 visible / 3 hidden categories
Core SQL case
InputA and B tie at 100
Expected[["A",100,1],["B",100,1],["C",90,2],["D",80,3]]
DENSE_RANK does not skip rank 2 after a tie.
Hidden Test Categories
Empty or missing matchesDuplicate rows or tiesNULL values where the pattern commonly breaks