What is SQL HAVING?
The SQL HAVING is a clause that enables conditions at the aggregate level. It is used instead of the WHERE clause when Aggregate Functions are used.
The SQL HAVING clause supports the same operators as the WHERE clause. Grouped results can be checked using this clause.
Why Use SQL HAVING?
The HAVING clause is used to SELECT information based aggregate information. For example, one may want to list sales representatives that have sales totaling over $10,000. This is very useful for analytical reporting.
How To Use SQL HAVING
SQL HAVING is used as follows.
SQL HAVING Syntax
SQL HAVING Example
The following example regions from the branch table that have total employee_count greater than 5.
Here are the contents of the table:
This SQL Statement with HAVING is executed:
Here is the result.