Assign Consecutive Dense Ranks to Decimal Scores. For each Scores row, report score and its rank: larger scores come first, ties share a rank, and the next different score receives the next integer without a gap. Sort the result.
### Problem
For each Scores row, report score and its rank: larger scores come first, ties share a rank, and the next different score receives the next integer without a gap. Sort the result by score descending. Keep repeated score rows.
### Local practice clarification
The original statement does not define missing-score ranking. For this adapted exercise, a NULL score ranks below every non-NULL score, and all NULL scores share one lowest tier. This is a curator clarification, not an original-source guarantee or a NOT NULL input constraint. Retain every row, including rows with missing scores.
### Tables
Table: `Scores`
```text
+-------------+---------+
| Column Name | Type |
+-------------+---------+
| id | int |
| score | decimal |
+-------------+---------+
id is the primary key (column with unique values) for this table.
Each row of this table contains the score of a game. Score is a floating point value with two decimal places.
```
### Example
```text
Scores (id,score): (1,8.20), (2,9.10), (3,8.20), (4,7.50)
Output (score,rank): (9.10,1), (8.20,2), (8.20,2), (7.50,3)
```
### Clarification example
```text
Scores (id,score): (1,NULL), (2,9.10), (3,NULL), (4,8.20), (5,8.20)
Output (score,rank): (9.10,1), (8.20,2), (8.20,2), (NULL,3), (NULL,3)
```
### What a Strong Answer Covers
- Return one row per input score, including repeated scores.
- Keep tied scores together and assign consecutive ranks to different scores.
- Honor the specified order and the rule for missing scores.
### Follow-up Questions
- How would the output change if ranks reset for each game?
- How would you return every score in the first three ranks, including ties at the cutoff?
Overview: Assign Consecutive Dense Ranks to Decimal Scores. For each Scores row, report score and its rank: larger scores come first, ties share a rank, and the next different score receives the next integer without a gap. Sort the result.
For each Scores row, report score and its rank: larger scores come first, ties share a rank, and the next different score receives the next integer without a gap. Sort the result by score descending. Keep repeated score rows.
Local practice clarification
The original statement does not define missing-score ranking. For this adapted exercise, a NULL score ranks below every non-NULL score, and all NULL scores share one lowest tier. This is a curator clarification, not an original-source guarantee or a NOT NULL input constraint. Retain every row, including rows with missing scores.
Tables
Table: Scores
+-------------+---------+
| Column Name | Type |
+-------------+---------+
| id | int |
| score | decimal |
+-------------+---------+
id is the primary key (column with unique values) for this table.
Each row of this table contains the score of a game. Score is a floating point value with two decimal places.