Both function as if they were
if , that is, they filter database rows.
WHERE works directly on the line,
HAVING works on line aggregator results, the most used is
GROUP BY .
Researching I concluded that it is actually expected that its use without an aggregator functions as a
WHERE , is not a coincidence, although it is a liberality, there is nothing in the specification that says it should be so. According to Jefferson Almeida in comment below, doing so is not portable among the SQL standard.
Some people even prefer to avoid it, using subquery and other mechanisms, by applying
WHERE to that result.
It is really important to ask why this is one of the cases that work may not be right, although I can not imagine what problem might cause in that case. Already using
WHERE when you want to filter the aggregate does not work.