Month-over-Month Change by Country

medium
Unit 14 · Window Functions VII0/3 to milestone

For each country and each month in which it had orders, return country, month (YYYY-MM), revenue, prev_revenue (revenue in that country's previous month with orders, or NULL) and pct_change (rounded to 1 decimal place, NULL for a country's first month). Sort by country, then month.

Schema

customers(id, name, country, signup_date)
orders(id, customer_id, order_date, total)
#window-functions#lag#growth1 visible + 1 hidden tests
query.sql · SQLite
Loading editor…
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
Month-over-Month Change by Country · TechGradify