Leaderboards at Meta must be fair and intuitive. When ranking scores, if two scores are identical, they should share the same ranking position. Crucially, the next ranking number after a tie should be the next consecutive integer (i.e., there should be no holes in the sequence).
Write an SQL query to rank the scores.
| id(INTEGER) | score(DECIMAL) |
|---|---|
| 1 | 3.5 |
| 2 | 3.65 |
| 3 | 4 |
| 4 | 3.85 |
| 5 | 4 |
| 6 | 3.65 |
| score(DECIMAL) | rank(INTEGER) |
|---|---|
| 4 | 1 |
| 4 | 1 |
| 3.85 | 2 |
| 3.65 | 3 |
| 3.65 | 3 |
| 3.5 | 4 |