hive窗口函数sort by多个字段

hive目前不支持sum over(sort by 多个字段),但是可以有另外一种解决方法:

在Hive里面,可以把over这一部分独立抽出来做声明。代码如下:

select  cloum1,cloum2,price,
sum(price) over w1 as s
from table
window w1 as (distribute by cloum1,cloum2 sort by cloum1,cloum2 rows between UNBOUNDED PRECEDING AND CURRENT ROW);

你可能感兴趣的:(hive窗口函数sort by多个字段)