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

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

Leetcode Solutions

Using Window Functions for Maximum Degree Days

  1. Use the ROW_NUMBER() window function to assign a row number to each entry, partitioned by city_id and ordered by degree descending and day ascending.
  2. Filter the results to only include rows where the row number is 1, which corresponds to the maximum degree day for each city.
  3. Select the city_id, day, and degree columns from the filtered results.
  4. Order the final result by city_id in ascending order.
erDiagram
    Weather {
        int city_id
        date day
        int degree
        city_id day PK
    }

Aggregation and Join for Maximum Degree Days

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...