ClickHouse/docs/en/sql-reference/statements/select/having.md
2022-03-29 22:06:21 -06:00

14 lines
712 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
sidebar_label: HAVING
---
# HAVING Clause {#having-clause}
Allows filtering the aggregation results produced by [GROUP BY](../../../sql-reference/statements/select/group-by.md). It is similar to the [WHERE](../../../sql-reference/statements/select/where.md) clause, but the difference is that `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.
## Limitations {#limitations}
`HAVING` cant be used if aggregation is not performed. Use `WHERE` instead.