How do I count rows per customer with SQL GROUP BY?
SELECT customer, COUNT(*) AS orders
FROM data
GROUP BY customer
ORDER BY orders DESC;
Run this query in QueryLocal →
`COUNT(*)` inside a `GROUP BY customer` query counts how many rows fall into each customer, rather than counting the whole table at once. Ordering by that count descending surfaces the most frequent customer first.
A table named data with columns: order_id (integer), customer (text), country (text), category (text), quantity (integer), unit_price (real), order_date (text, YYYY-MM-DD).