Hive 求月销售额和总销售额

发布时间:2020-06-09 22:57:48 作者:zjy1002261870
来源:网络 阅读:525

求月销售额和总销售额
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

推荐阅读:
  1. hive分区和分桶的示例分析
  2. hive的典型应用场景

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

hive sum over

上一篇:Fruit Ninja(水果忍者)游戏源代码下载、分析(上)---可运行Android,Ios,Window,Mac,Html5平台

下一篇:零基础如何学Linux

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》