您当前的位置: 首页 >  hive

59 Hive案例(级联求和)

杨林伟 发布时间:2019-08-08 17:00:58 ,浏览量:2

需求

有如下访客访问次数统计表 t_access_times 在这里插入图片描述 需要输出报表:t_access_times_accumulate 在这里插入图片描述

实现步骤

可以用一个hql语句即可实现:

select A.username,A.month,max(A.salary) as salary,sum(B.salary) as accumulate
from 
(select username,month,sum(salary) as salary from t_access_times group by username,month) A 
inner join 
(select username,month,sum(salary) as salary from t_access_times group by username,month) B
on
A.username=B.username
where B.month             
关注
打赏
1688896170
查看更多评论
0.0854s