Rank Scores with No Gaps
Rank Scores with No Gaps
MediumSQL0% accepted
Given a Scores table with Id and Score, rank the scores with no gaps in ranking. Same scores should get the same rank, and the next different score should get the next consecutive rank.
Approach
Rank scores using DENSE_RANK with no gaps for tied scores.
Input
Scores: [3.50, 3.65, 4.00, 3.85, 4.00, 3.65]
Output
4.00->Rank1, 4.00->Rank1, 3.85->Rank2, 3.65->Rank3, 3.65->Rank3, 3.50->Rank4
More SQL problems
Browse all coding problems →Scenarios & Expected Answers
Sign in to continue
Create a free account to view answers and mark progress.
- Free forever — no credit card
- Theory Q&A with detailed answers
- Points, streaks & leaderboards