SQL面试题-数据转换-窗口函数应用

阅读 48

2022-07-04

SQL面试题-数据转换-窗口函数应用_sql

hive> select * from temp;
OK
1 abc 10
1 def 15
1 xyz 20
2 abc 13
2 xyz 40
3 def 50
3 abc 60
Time taken: 0.282 seconds, Fetched: 7 row(s)
hive> select cn,dt,sum(point) over(partition by cn order by dt) as sumpoint from temp order by sumpoint;
OK
abc 1 10
def 1 15
xyz 1 20
abc 2 23
xyz 2 60
def 3 65
abc 3 83
Time taken: 9.746 seconds, Fetched: 7 row(s)

SQL如下

select cn,dt,sum(point) over(partition by cn order by dt) as sumpoint from temp order by sumpoint;


精彩评论(0)

0 0 举报