Databases · Middle · Question 27 of 75
How do you compute a running total of payments per user?
- 1
RUNNING_SUM(amount) - ✓Correct answer:
SUM(amount) OVER (PARTITION BY user_id ORDER BY paid_at) - 3
SUM(amount) GROUP BY paid_at
Explanation
With ORDER BY inside OVER, the window by default goes from the start of the partition to the current row (including rows with the same sort value).