Practice · hard · dataset: ecom

Cumulative revenue by month

Finance wants a year-to-date revenue curve. For each month present in the order data, return that month’s revenue and the cumulative revenue from the earliest month through the end of that month.

Revenue is the sum of quantity * unit_price across all line items for orders placed in the month, regardless of status.

Return month (the first day of the month), revenue, and cumulative_revenue, with both money columns rounded to two decimals. Sort by month ascending.

Tables available

Table Columns
orders order_id, customer_id, order_date, status, channel
order_items order_id, product_id, quantity, unit_price

The cumulative value must include the current month’s revenue, not stop before it.

⌘/Ctrl + Enter to grade

Write a query, then grade it.

Hints

Try it first. Reveal a hint only when you are stuck.