select t1.Id,
t1.Name,
t1.SalaryDeduction,
Salary,
Case when (t1.Salary < 12000 ) then t1.Salary + 500 else t1.Salary end Salary,
(
select Sum(t.Salary)
from #temp t where t.Id <= t1.Id
) as totalSalary
from #temp t1
Output-
Id Name SalaryDeduction Salary Salary totalSalary
1 A 1000.00 10000.00 10500.00 10000.00
2 B 2000.00 15000.00 15000.00 25000.00
3 C 500.00 10000.00 10500.00 35000.00
4 D 200.00 20000.00 20000.00 55000.00
5 E 150.00 12000.00 12000.00 67000.00
6 F 1400.00 13000.00 13000.00 80000.00
t1.Name,
t1.SalaryDeduction,
Salary,
Case when (t1.Salary < 12000 ) then t1.Salary + 500 else t1.Salary end Salary,
(
select Sum(t.Salary)
from #temp t where t.Id <= t1.Id
) as totalSalary
from #temp t1
Output-
Id Name SalaryDeduction Salary Salary totalSalary
1 A 1000.00 10000.00 10500.00 10000.00
2 B 2000.00 15000.00 15000.00 25000.00
3 C 500.00 10000.00 10500.00 35000.00
4 D 200.00 20000.00 20000.00 55000.00
5 E 150.00 12000.00 12000.00 67000.00
6 F 1400.00 13000.00 13000.00 80000.00
No comments:
Post a Comment