Loading problem...
You are given a table named Scores with the following columns:
Your task is to produce a ranked leaderboard using dense ranking rules:
Return one output row for every row in Scores, with exactly these columns and order:
Final output should be ordered by score descending.
This problem must be solvable in both:
Scores:
| id | score |
|----|-------|
| 1 | 3.50 |
| 2 | 3.65 |
| 3 | 4.00 |
| 4 | 3.85 |
| 5 | 4.00 |
| 6 | 3.65 |[
{"score": 4.0, "rank": 1},
{"score": 4.0, "rank": 1},
{"score": 3.85, "rank": 2},
{"score": 3.65, "rank": 3},
{"score": 3.65, "rank": 3},
{"score": 3.5, "rank": 4}
]Both rows with score 4.00 receive rank 1. The next distinct score (3.85) receives rank 2, and rank numbers remain consecutive without gaps.
Scores:
| id | score |
|----|-------|
| 7 | 9.10 |
| 8 | 8.25 |
| 9 | 7.75 |[
{"score": 9.1, "rank": 1},
{"score": 8.25, "rank": 2},
{"score": 7.75, "rank": 3}
]All scores are distinct, so ranks are simply 1, 2, and 3 in descending score order.
Scores:
| id | score |
|----|-------|
| 10 | 5.00 |
| 11 | 5.00 |
| 12 | 5.00 |[
{"score": 5.0, "rank": 1},
{"score": 5.0, "rank": 1},
{"score": 5.0, "rank": 1}
]When all rows have the same score, every row receives dense rank 1.
Constraints