Allows filtering the aggregation results produced by GROUP BY. It is similar to the WHERE clause, but the difference is thatDocumentation Index
Fetch the complete documentation index at: https://private-7c7dfe99-page-updates.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
WHERE is performed before aggregation, while HAVING is performed after it.
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.
Example
If you have asales table as follows:
Limitations
HAVING can’t be used if aggregation is not performed. Use WHERE instead.