Home › SQL Tutorial › SQL GROUP BY and HAVING
SQL GROUP BY and HAVING
Summarise rows by group.
GROUP BY makes one row per group so aggregates work per group. WHERE filters rows before grouping; HAVING filters the groups after.
Example code
SELECT country, COUNT(*) AS total
FROM Customers
GROUP BY country
HAVING COUNT(*) > 1;