It is possible to reference aggregation results from
SELECT clause in
HAVING clause by their alias. Alternatively,
HAVING clause can filter on results of additional aggregates that are not returned in query results.
HAVING can’t be used if aggregation is not performed. Use