SQL interview question: running revenue total by city

EasyRunning total

Problem

Shared data rules

For each city, compute daily revenue for Sep 1–27, 2026 and a running total from the start of the month.

Example

Input: orders
order_idcreated_atstatuscityamount_usd
2012026-09-01 10:40deliveredBoston30
2022026-09-01 12:15deliveredBoston46
2032026-09-02 11:10deliveredBoston16
2042026-09-02 14:00deliveredNew York62
2052026-09-03 19:30deliveredBoston24
Output
cityorder_dateday_revenuecumulative_revenue
Boston2026-09-017676
Boston2026-09-021692
Boston2026-09-0324116
New York2026-09-026262

Boston: $76 on Sep 1, then $76 + $16 = $92 and $92 + $24 = $116. New York has its own total — $62.

Solve it free

Your query runs on PostgreSQL in your browser. No sign-up needed.

Skills it tests

More interview questions

All questions