问题描述
表名是员工
EmpNo EmpName薪水
1 A 2000
2 B 1000
3 C 3000
4 D 2000
5 E 5000
我需要通过添加前一行和当前行的工资再获得一列
NewSal
2000
3000
4000
5000
7000
我尝试过:
选择EmpNo,
EmpName,薪水,(SELECT SUM(薪水)FROM Employee e1 WHERE
e1.EmpNo< = e2.EmpNo)作为T_Sal
来自员工e2
我试过这个查询但这给了我添加所有先前的行
Table Name is Employee
EmpNo EmpName Salary
1 A 2000
2 B 1000
3 C 3000
4 D 2000
5 E 5000
I need to get one more column by adding salary of previous and current row as
NewSal
2000
3000
4000
5000
7000
What I have tried:
Select EmpNo,
EmpName, Salary,(SELECT SUM(salary) FROM Employee e1 WHERE
e1.EmpNo <= e2.EmpNo)as T_Sal
FROM Employee e2
I tried this query but this is giving me the addition of all previous rows
推荐答案
这篇关于仅添加上一行和当前行的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!