标签:alt 数据 join mit 访问 src http nat format
u01 2019/1/21 5
u02 2019/1/23 6
u03 2019/1/22 8
u04 2019/1/20 3
u01 2019/1/23 6
u01 2019/2/21 8
u02 2019/1/23 6
u01 2019/2/22 4
create table action (userId string, visitDate string, visitCount int) row format delimited fields terminated by "\t";
create table action_amount
as
select tmp.userid,tmp.month,sum(tmp.visitcount) amount from (select userid,from_unixtime(unix_timestamp(visitdate,‘yyyy/mm/dd‘),‘yyyy-mm‘) month,visitcount from action) tmp group by tmp.userid,tmp.month;
create table action_tmp
as
select a.amount as a_amount,b.*
from action_amount a join action_amount b on a.userid=b.userid
where a.month <= b.month;
select userid,month,max(amount) as amount,sum(a_amount) as accumulate
from action_tmp
group by userid,month;
标签:alt 数据 join mit 访问 src http nat format
原文地址:https://www.cnblogs.com/zhangchenchuan/p/11973764.html