The HAVING Clause is always used after the GROUP BY clause, it can not come without the GROUP BY clause. It works the same as the WHERE Clause, it is therefore also used to apply conditions on the aggregate_functions which was impossible by using simple WHERE clause.
The HAVING clause simply contains the conditions to filter data just like in WHERE clause.
SQL HAVING Syntax
Consider the following table for this exercise
Result of the Query
The data in the above example is first grouped using the Salary and DeptID column. The result is calculated using the AVG function and since the WHERE clause is not applicable here we use the HAVING Clause. The salary returned is those that meet the criteria which is above average of $2000.