By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
totalSalary | nextTotalSalary | ( case when isnull(r.nextTotalSalary)= 1 then r.totalSalary else nextTotalSalary end ) - r.totalSalary |
---|---|---|
10000 | 12000 | 2000 |
12000 | 15000 | 3000 |
15000 | null | 0 |