having - 函数输出限制
引用:https://zhidao.baidu.com/question/406745181.html
对函数输出进行限制
栗子:
比如,我们可能只希望看到Store_Information数据表中销售总额超过1500美圆的商店的信息,这时我们就需要使用HAVING从句。语法格式为:
SELECT "column_name1", SUM("column_name2")
FROM "table_name"
GROUP BY "column_name1"
HAVING (arithematic function condition)
SELECT store_name, SUM(sales)
FROM Store_Information
GROUP BY store_name
HAVING SUM(sales) > 1500
having放在groupby语句作为子句存在
整理:
select 分组列名,聚合函数 from 表名 group by 分组列 having 条件