sql
Running total of daily revenue
SQL & Data Modeling · Window Functions · medium · Original Uplift question · PostgreSQL · 10 min
From the orders table, return each order_date with that day's revenue and a cumulative running total of revenue through that date, ordered by date.
Fixture
orders
order_id, order_date, amount
create table orders (order_id int, order_date date, amount numeric); insert into orders values (1,'2026-01-01',120),(2,'2026-01-01',80),(3,'2026-01-02',200), (4,'2026-01-03',50),(5,'2026-01-03',60),(6,'2026-01-04',300);
Evaluation criteria
- Aggregates revenue to one row per date
- Uses a windowed SUM ordered by date for the running total
- Running total is cumulative (monotonic non-decreasing)
- Ordered by order_date
Detailed grading feedback appears after you submit.
Source
Original Uplift question based on a common interview pattern.
Your answer
You get one graded attempt here without an account. Create a free account for unlimited attempts, saved progress and community write-ups.
Answers stay hidden until you ask. Reveal the full model write-up when you are ready to compare.