1.只有在分组之后,可以在select里面使用聚合函数
select name,sum(price) from product group by name
2.having——进行分组之后的过滤操作
where只能进行分组前的过滤,分组后的过滤工作只有having才能做
where语句中不允许使用聚合函数,having语句中允许使用聚合函数
例:查询总价大于100元的商品的名称
select name,sum(price) from product group by name having sum(price)>100
例:查找单价小于100,总价大于100的商品
select name,sum(price) from product where price<100 group by name having sum(price)>100