Sobes.tech
Middle

What is the purpose of the HAVING operator?

sobes.tech AI

Answer from AI

The HAVING operator in SQL is used to filter groups of records formed with GROUP BY. Unlike WHERE, which filters individual rows before grouping, HAVING is applied after grouping and allows conditions on aggregate functions such as SUM, COUNT, AVG.

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 the purpose of the HAVING operator? — System… - sobes.tech