create table money
(
user_id string,
month string,
money int
) row format delimited fields terminated by ',';
load data local inpath '/root/hivedata/money.txt' overwrite into table money;
select *
from money;
select user_id,
month,
sum(money) month_money
from money
group by user_id, month;
with tmp_money as (
select user_id,
month,
sum(money) month_money
from money
group by user_id, month
)
select user_id,
month,
month_money,
sum(month_money) over (partition by user_id order by month
) as sum_month_money
from tmp_money;