42. Orders Per Customer
EasyAggregationGROUP BYCOUNT
GROUP BY collapses rows that share a value into one group, and aggregate functions like COUNT(*) summarize each group.
Task: for each customer, return how many rows they have in the orders table.
Return columns customer, order_count. Order by order_count descending, then customer ascending.
Tables
Loading schema…
Expected outputrows must come back in this order
Computing expected output…
This is the result for the example data above. On Submit your query is graded against this example plus 4 hidden edge cases — 5test cases in all. A sloppy query that only fits the example won't pass.
SQL· SQLite · runs in your browser
⌘/Ctrl+↵ run · ⇧⌘/Ctrl+↵ submit
Run a query to see its output here.