SQL: Running Total
Medium
SQL — Window Functions
SQL
Running Total
OVER
Calculate running total of sales.
Constraints
Write standard SQL (MySQL 8.0 compatible).
Examples
Example 1:
Input: date amount
1 100
2 200
3 150
Output:
Example 2:
Input: date amount
1 100
2 200
3 150
Output:
Hints
SUM() OVER(ORDER BY date).
Tests:
Runtime:
Memory:
Test
Input:
Expected:
Got:
Click Run Code to test against sample cases, or Submit to test against all cases.
▲ Console