you can use row_number()
to be used for left join
your previous balance
.
select t1.*, t2.PrevBalance from
(select Date, PrevBalance, AddedAmount,
row_number() over (order by Date asc) as rn
from tableA) t1
left join
(select Date, PrevBalance, AddedAmount,
row_number() over (order by Date asc) as rn
from tableA) t2 on t2.rn + 1 = t1.rn
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…