Revenue by buyer country
Calculate completed-order revenue by customer country. Return country and revenue_cents. All orders use USD regardless of customer country; no FX conversion is needed. Row order does not matter.
Output
countryrevenue_centsquery.sql
DuckDB SQLRestoring your saved draft…
Run a query to see results.
Reveal solution & explanation
SELECT c.country, SUM(o.order_total_cents) AS revenue_cents FROM customers c JOIN orders o ON c.customer_id = o.customer_id WHERE o.status = 'completed' GROUP BY c.country;
The customer join is many orders to one customer, preserving the order grain before aggregation.
Data & schema
- customer_id
- INTEGER · PK
- customer_name
- VARCHAR
- country
- VARCHAR
- VARCHAR
- signup_date
- DATE
Table notes & relationships
Buyer accounts. Some buyers have no orders, and some email addresses are NULL.
Fictional teaching data. Money is USD cents; timestamps are UTC.