What is the difference between the
GROUP BY is not used, the
HAVING clauses are essentially equivalent.
GROUP BYis used:
WHEREclause is used to filter records from a result. The filtering occurs before any groupings are made.
HAVINGclause is used to filter values from a group (i.e., to check conditions after aggregation into groups has been performed).