101
0/304
Loading content...
A climate observability platform stores daily degree readings for multiple cities and needs a canonical peak-day snapshot for reporting dashboards.
Table: Weather
Data guarantee:
Task: For each city_id, return exactly one row representing that city's highest recorded degree. If the highest degree appears on multiple days for the same city, choose the earliest day among those ties.
Output requirements:
Supported submission environments:
Weather:
| city_id | day | degree |
|---------|------------|--------|
| 1 | 2022-01-07 | -12 |
| 1 | 2022-03-07 | 5 |
| 1 | 2022-07-07 | 24 |
| 2 | 2022-08-07 | 37 |
| 2 | 2022-08-17 | 37 |
| 3 | 2022-02-07 | -7 |
| 3 | 2022-12-07 | -6 |[
{"city_id":1,"day":"2022-07-07","degree":24},
{"city_id":2,"day":"2022-08-07","degree":37},
{"city_id":3,"day":"2022-12-07","degree":-6}
]City 2 reaches the same maximum degree on two dates; the earlier date 2022-08-07 is selected.
Weather:
| city_id | day | degree |
|---------|------------|--------|
| 10 | 2022-01-01 | 15 |
| 10 | 2022-01-02 | 15 |
| 10 | 2022-01-03 | 9 |
| 11 | 2022-11-15 | -2 |
| 11 | 2022-11-16 | -2 |[
{"city_id":10,"day":"2022-01-01","degree":15},
{"city_id":11,"day":"2022-11-15","degree":-2}
]When all top values are tied, choose the earliest day per city.
Weather:
[][]No city records means no output rows.
Constraints