Running Balance
deposits has one row per day, and a negative amount is money taken out. Return every day with its amount and running: the sum of all amounts up to and including that day. Earliest day first.
Example 1
deposits
| day | amount |
|---|---|
| 2026-01-05 | 100 |
| 2026-01-02 | 50 |
| 2026-01-09 | -30 |
| 2026-01-07 | 20 |
returns
| day | amount | running |
|---|---|---|
| 2026-01-02 | 50 | 50 |
| 2026-01-05 | 100 | 150 |
| 2026-01-07 | 20 | 170 |
| 2026-01-09 | -30 | 140 |
Constraints
- Up to 12 days, each day once
Write it in your browser, against the clock. The model query, with a note on each piece of it, comes after.
More SQL problems
- Second From the TopMedium
- Share of the TotalMedium
- Volume Weighted PriceMedium
- Chain of CommandHard
- Daily BarsHard
- Longest Winning StreakHard
- Median SalaryHard
- Month Over MonthHard