当前位置:   article > 正文

Hive 窗口函数如何设置窗口大小_hive sum over partition by 窗口大小

hive sum over partition by 窗口大小
select city,year,taxes,
 
sum(money) over() as sample1,--所有行相加
 
sum(money) over(partition by city) as sample2,--按city分组,组内数据相加
 
sum(money) over(partition by city order by year) as sample3,--按city分组,组内数据累加
 
sum(money) over(partition by city order by year rows between UNBOUNDED PRECEDING and current row ) as sample4 ,--和sample3一样,由起点到当前行的聚合
 
sum(money) over(partition by city order by year rows between 1 PRECEDING and current row) as sample5, --当前行和前面一行做聚合
 
sum(money) over(partition by city order by year rows between 1 PRECEDING and 1 FOLLOWING ) as sample6,--当前行和前边一行及后面一行
 
sum(money) over(partition by city order by year rows between current row and UNBOUNDED FOLLOWING ) as sample7 --当前行及后面所有行
 
from business;
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/在线问答5/article/detail/781990
推荐阅读
相关标签
  

闽ICP备14008679号