sql
Month-over-month revenue growth
SQL & Data Modeling · Window Functions · medium · Original Uplift question · PostgreSQL · 10 min
Return each month, its revenue, and the month-over-month growth as a percentage rounded to one decimal. The first month has no prior month, so its growth is null.
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-05',1000),(2,'2026-01-20',500),(3,'2026-02-10',1800), (4,'2026-03-02',900),(5,'2026-03-15',900);
Evaluation criteria
- Truncates dates to month and aggregates revenue
- Uses LAG to get prior-month revenue
- Growth = (cur - prev)/prev * 100, rounded to 1 decimal
- Handles the first month (null growth) without dividing by zero
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.