I want to get the balance via T-SQL from this table
TID amount balance
--- ----- -------
1 100 100
2 50 150
3 30 180
4 300 480
5 200 680
Can anyone please support me on this case?
Best regards.
I want to get the balance via T-SQL from this table
TID amount balance
--- ----- -------
1 100 100
2 50 150
3 30 180
4 300 480
5 200 680
Can anyone please support me on this case?
Best regards.
One way is using window function sum
:
select
t.*,
sum(amount) over (order by tid) balance
from your_table t;