Leetcode Problem 1308. Running Total for Different Genders

1308. Running Total for Different Genders

Leetcode Solutions

Window Function for Running Total

  • Use the SELECT statement to choose the columns gender, day, and the calculated total score.
  • Apply the SUM() function as a window function over the score_points column.
  • Partition the result set by gender to calculate the total separately for each gender.
  • Order the result set within each partition by day to ensure the scores are summed in chronological order.
  • Use the OVER() clause to define the window specification.
  • Order the final result by gender and day in ascending order.
erDiagram
    Scores {
        varchar player_name
        varchar gender
        date day
        int score_points
        gender_day PK gender day
    }

Self-Join for Running Total

Ask Question

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

Suggested Answer

Answer
Code Diffs Compare
Full Screen
Copy Answer Code
Loading...