group by 用法

一、在用group by 时,select 中的字段要么出现在聚合函数中,要么出现在group by中,不能独立于两者外。例如:

select id,deal_id,price,max(date) 
from order 
where date>'2017-08-01'
group by id,deal_id,price

二、在group by 后面跟having时,having后只能跟原函数不能跟别名(spark数据查询)。

你可能感兴趣的:(group by 用法)