标签:view for hive and pre order create row from
求月销售额和总销售额create table t_store(
name string comment ‘店铺‘,
months int comment ‘月份‘,
money int comment ‘金额‘
)
row format delimited fields terminated by ",";
load data local inpath "/root/t_store.txt" into table t_store;
create view v_t_store
as
select name,months,sum(money) money
from t_store
group by name,months;
select name,months,money
,sum(money) over(partition by name order by months rows between unbounded preceding and current row) as t_money
from v_t_store;
a 1 350 350
a 2 5000 5350
a 3 600 5950
b 1 7800 7800
b 2 2500 10300
c 1 470 470
c 2 630 1100
标签:view for hive and pre order create row from
原文地址:http://blog.51cto.com/6000734/2321914