Write a SQL query using window functions to rank records within each group and return the top row per group.
Use the provided record_groups and records tables. Rank by score descending, place NULL scores after non-NULL scores, and use the smallest record_id as the tie-breaker.
group_id, group_name, record_id, record_name, score, and rank_positiongroup_id| Column | Type | Description |
|---|---|---|
| group_idPK | INT | Unique identifier for a record group |
| group_name | VARCHAR(100) | Name of the record group |
| Column | Type | Description |
|---|---|---|
| record_idPK | INT | Unique identifier for a record |
| group_id | INT | Identifier of the record group |
| record_name | VARCHAR(100) | Descriptive name of the record |
| score | INT | Ranking score for the record |