Trailing 7 days: see the last week from every day
Weekly financial report: for every day we need the sum of revenue over the last seven days inclusive (this day plus the previous six). This view is often called «trailing 7-day». For every day compute that rolling sum. For the first six days the window is physically smaller than seven — that's fine, the result is still valid (just the sum of whatever is there). Sort by day.
Expected output sample
This is what a correct answer looks like — its row count is its own, it doesn't have to match the schema tables.
| d | sum_7d |
|---|---|
| 2024-01-01 | 100.00 |
| 2024-01-02 | 220.00 |
| 2024-01-03 | 330.00 |
Sign in to see submission history
Sign inSign in to use AI Mentor
Sign in