MySQL SQL

MySQL GROUP BY

Group rows for aggregate calculations.

SELECT category, COUNT(*) AS product_count
FROM products
GROUP BY category;

Non-aggregated selected columns normally belong in the GROUP BY list.