Blog · Guide
How SQL GROUP BY Works (Buckets + Totals)
GROUP BY splits rows into groups that share a value, then lets you COUNT/SUM each group — cities, categories, statuses.
Group, then aggregate
SELECT city, COUNT(*) AS customers FROM customers GROUP BY city;
One result row per distinct city. Every non-aggregated column in SELECT must appear in GROUP BY.
Mental picture
Imagine sorting index cards into piles by city, then writing a sticky note on each pile: “7 customers.” That’s GROUP BY + COUNT.
Try it yourself
The fastest way to lock this in is a short drill on the same Northstar Market tables.