The HAVING clause can be used when we want to retrieve the values of these functions for only those groups that satisfy certain conditions.
SELECT <attr list>
FROM <table>
[WHERE <cond>]
GROUP BY <grouping attr>
HAVING <cond>For example, we could use the HAVING condition COUNT(*) > 2 to select all the sub-groups that have 3 or more rows.