栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 前沿技术 > 大数据 > 大数据系统

Hive 开窗函数 rows between current row and unbounded following 的使用

Hive 开窗函数 rows between current row and unbounded following 的使用

1.rows between的作用
在使用hsql完成一些业务需求的时候,我们经常会用到窗口函数,某些场景
下会涉及到需要控制窗口函数的范围来满足业务需求,这个时候就需要用到rows
between了,使用rows between可以根据自己的需求任意的控制窗口函数的范围。
2.模拟数据,建表
create external table if not exists t_sale_info
(
sid bigint
, day_time string
, sales_volume bigint
)
row format delimited fields terminated by ','
stored as textfile
location '/user/hive/warehouse/sale_info';

3.函数使用效果

select sid
,day_time
,sales_volume
,sum(sales_volume) over (partition by sid order by day_time rows between current row and unbounded following) as rows_sum1
,sum(sales_volume) over (partition by sid order by day_time)   as rows_sum2
from t_sale_info

## rows between current row and unbounded following
## 功能: 在开窗的时候,最后一行开始与当前进行操作
## 对比正常开窗,从第一行开始知道当前行进行操作 

 

 

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/761909.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号