List Each Customer's Orders in One Row

medium
Unit 21 · Aggregation & Joins II0/3 to milestone

Return each customer with orders: name and order_ids, a comma-separated list of their order ids (no spaces) in date order (ties by id). Sort by name.

SQLite's GROUP_CONCAT doesn't take an ORDER BY in older versions, so sort in a subquery first.

Schema

customers(id, name, country, signup_date)
orders(id, customer_id, order_date, total)
#aggregation#strings1 visible + 1 hidden tests
query.sql · SQLite
Loading editor…
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
List Each Customer's Orders in One Row · TechGradify