2020-08-14 09:17
中国传媒大学 数据分析师 牛客112736836号:可以先进行表连接再用group by 获取running_total 代码如下:select s.emp_no, s.salary, t.running_total from salaries as s left join (select s1.emp_no, sum(s2.salary) as running_total from (select emp_no, salary from salaries where to_date='9999-01-01' ) as s1 left join (select emp_no, salary from salaries where to_date='9999-01-01' ) as s2 on s1.emp_no >=s2.emp_no group by s1.emp_no) as t on s.emp_no = t.emp_no where to_date = '9999-01-01'
0 点赞 评论 收藏
分享
关注他的用户也关注了: