select * from pt_test
NO,NAME
-21,hello
4,hello
1,hello2
4,hello2
5,hello
10,hello
select no, name, sum(no) over (partition by name ) value ,
sum(no) over (partition by name order by no range unbounded preceding) preceding from pt_test
NO,NAME,VALUE,PRECEDING
-21,hello,-2,-21
4,hello,-2,-17
5,hello,-2,-12
10,hello,-2,-2
1,hello2,5,1
4,hello2,5,5
No comments:
Post a Comment