PostgreSQL
PostgreSQL GROUP BY
Group rows with the same value for aggregate calculations.
Group and count
SELECT year, COUNT(*) AS product_count
FROM products
GROUP BY year
ORDER BY year;Every selected column that is not aggregated must be included in the GROUP BY clause.