更新时间:2024-11-11 GMT+08:00

HAVING

完整的分析语句语法如下:

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

其中,HAVING子句用于指定过滤分组结果(GROUP BY)或聚合计算结果的条件。本章节内容将介绍HAVING语法参数说明及示例。

在分组的基础上,结合聚合函数来筛选数据。

SELECT age, MAX(balance) GROUP BY age HAVING MIN(balance) > 10000
表1 HAVING

age

MAX(balance)

28

32838

32

39225