Sobes.tech
Middle+

What is HAVING in SQL?

sobes.tech AI

Answer from AI

The SQL HAVING operator is used to filter results after grouping data with GROUP BY.

While WHERE filters rows before grouping, HAVING filters groups after aggregation.

Example:

SELECT department, COUNT(*) AS employee_count
FROM employees
GROUP BY department
HAVING COUNT(*) > 10;

This query will select only those departments with more than 10 employees.

What is HAVING in SQL? — System Analyst - sobes.tech