Pivot: Revenue by Country and Month

medium
Checkpoint challenge
Solve this to show you know the material and jump straight to Unit 19. Everything before it counts as cleared.

Finance wants a spreadsheet-style table: one row per country, one column per month.

Return country, jan, feb and mar: the country's revenue in January, February and March 2024, with 0 for months without orders. Include every country that has at least one order (in any month), sorted by country.

SQLite has no PIVOT keyword. Use conditional aggregation.

Schema

customers(id, name, country, signup_date)
orders(id, customer_id, order_date, total)
#pivot#conditional-aggregation#case1 visible + 1 hidden tests
query.sql · SQLite
Loading editor…
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
Pivot: Revenue by Country and Month · TechGradify