HAVING
HAVING is a SQL clause in the SELECT Queries category. Filters groups after aggregation (WHERE filters rows before aggregation). The syntax is SELECT column, agg_func(col) FROM table GROUP BY column HAVING condition;. It returns filtered groups. A typical example: SELECT department, AVG(salary) FROM employees GROUP BY department HAVING AVG(salary) > 60000; -- Departments where average salary exceeds 60000 A close relative is SELECT, which retrieves data from a table. The most fundamental SQL statement. A close relative is SELECT *, which selects all columns from a table. A close relative is SELECT DISTINCT, which returns only distinct (unique) values from the specified columns. More about this category: Core SELECT query clauses — SELECT, FROM, WHERE, GROUP BY, HAVING, ORDER BY, LIMIT. Related SELECT Queries entries: SELECT, SELECT *, SELECT DISTINCT, WHERE, AND / OR / NOT, IN, BETWEEN, LIKE.