Practice · hard · dataset: ecom

Revenue growth rate by month

A growth report needs the month-over-month percentage change in revenue. 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, previous_revenue, and growth_percent. Round revenue and previous revenue to two decimals, and round growth_percent to two decimals as a percentage (for example, a rise from 100 to 110 is 10.00).

The first month has no previous month, so its previous_revenue and growth_percent must be NULL. 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

A month that follows a zero-revenue month has no meaningful percentage change; let nullif produce NULL rather than raising a division-by-zero error.

⌘/Ctrl + Enter to grade

Write a query, then grade it.

Hints

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