The HAVING
clause is used when you want to specify a condition for a group function and it is written after the GROUP BY
clause. The WHERE
clause is used when you want to specify a condition for columns, and single row functions except group functions, and it is written before the GROUP BY
clause if it is used.