Unit 7 · GROUP BY, COUNT
Counting with GROUP BY
Orders by status
GROUP BY collapses many rows into one row per distinct value. An aggregate function such as COUNT, SUM or AVG then calculates one number for each group.
SELECT category, COUNT(*) AS products
FROM products
GROUP BY category;Your task
Operations wants a quick health check. How many orders are in each status? Show the most common status first.
Tables you will use: orders
Try it in your browserFree, no sign-up. Your query is checked as you go.