All SQL problems
MediumJOIN
Which categories has each city bought?
For each city, list the distinct product categories that customers there have ever ordered. Sort by city, then category.
- #distinct
Schema (SQLite, in-browser)
customers (id, name, city, signup_date) products (id, name, category, price) orders (id, customer_id, order_date, status) order_items (order_id, product_id, quantity)
Sample input
4 cities, 3 categories
Expected shape
up to 12 rows
sql-distinct.sqlSQLite
Result
Press “Run query” to execute against the sample database.
