溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

Hive 求月銷售額和總銷售額

發(fā)布時(shí)間:2020-06-09 22:57:48 來(lái)源:網(wǎng)絡(luò) 閱讀:529 作者:zjy1002261870 欄目:大數(shù)據(jù)

求月銷售額和總銷售額
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 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

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI