GROUP BY and HAVING in MySQL

Published July 26, 2025 By Sai Sree Ram Gundepudi

GROUP BY

SELECT department, COUNT(*) FROM employees GROUP BY department;

HAVING

SELECT department, COUNT(*) AS total 
FROM employees
GROUP BY department
HAVING total > 5;

Was this solution helpful?

Your feedback helps improve our technical knowledge repository.

Share this article