- 5 每个店铺的当月销售额和累计到当月的总销售额
店铺,月份,金额
a,01,150
a,01,200
b,01,1000
b,01,800
c,01,250
c,01,220
b,01,6000
a,02,2000
a,02,3000
b,02,1000
b,02,1500
c,02,350
c,02,280
a,03,350
a,03,250
create table if not exists sale(
id string,
month string,
money int
)
row format delimited fields terminated by ','
lines terminated by '\n'
stored as textfile
;
load data local inpath '/root/hivedata/sale.txt' into table sale;
select
id,
month,
sm,
sum(sm) over(distribute by id sort by month)
from
(select
id,
month,
sum(money) sm
from sale
group by id,month) t1
;
