Updated on 2026-05-15 GMT+08:00

HAVING

Syntax of Analysis Statements

The syntax of a complete analysis statement is as follows:

1
2
3
4
SELECT [DISTINCT] (* | expression) [AS alias] [, ...]
[GROUP BY expression [, ...] [HAVING predicates]]
[ORDER BY expression [ASC | DESC] [, ...]]
[LIMIT size OFFSET offset]

The HAVING syntax specifies the conditions for filtering group results (GROUP BY) or aggregation calculation results. The following part describes parameters and examples for the HAVING syntax.

Example statement: Query data where the value of MIN(balance) exceeds 10000 and group the values of MAX(balance) by age.

Filters data based on grouping and Aggregate Functions.

1
*|SELECT age, MAX(balance) GROUP BY age HAVING MIN(balance) > 10000
Table 1 The HAVING function

age

MAX(balance)

28

32838

32

39225