Skip to content

2314. The First Day of the Maximum Recorded Degree in Each City 👍

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
WITH
  RankedWeather AS (
    SELECT
      *,
      RANK() OVER(
        PARTITION by city_id
        ORDER BY degree DESC, day
      ) AS `rank`
    FROM Weather
  )
SELECT city_id, day, degree
FROM RankedWeather
WHERE `rank` = 1;