题解 | #统计salary的累计和#
统计salary的累计和running_total
https://www.nowcoder.com/practice/58824cd644ea47d7b2b670c506a159a6
select emp_no,salary,sum(salary) over (order by emp_no) as running_total from salaries where to_date ='9999-01-01'
窗口函数的使用
sum(a) over (order by b) 的含义是:
例如:
a b
1 2
3 4
5 6
按照b列排序,将a依次相加,得到结果,如下:
a b sum(a) over (order by b):
1 2 1
3 4 1+3
5 6 1+3+5