hello, hello.
i have need to create an account sheet. listing the bookings row by row (of course). at the end of each row i need the balance/saldo (of this account, in this row). Since this is an intermediate value I struggle to calculate it. I thought I simply could set the new saldo value in every line and i would be fine.... doesn't work that way.
So here's my question: How can i calculate intermediate values that change line by line?
Thanks heaps.
my failing example
=====================
DECLARE @saldo float
SELECT ID, Active, Passive, Text, Date, (@saldo = @saldo - Active) as saldo
FROM F_AA_BalanceSheet
WHERE accountID = 4020 AND year(date) = year(getdate())
ORDER BY DATE DESC
i have need to create an account sheet. listing the bookings row by row (of course). at the end of each row i need the balance/saldo (of this account, in this row). Since this is an intermediate value I struggle to calculate it. I thought I simply could set the new saldo value in every line and i would be fine.... doesn't work that way.
So here's my question: How can i calculate intermediate values that change line by line?
Thanks heaps.
my failing example
=====================
DECLARE @saldo float
SELECT ID, Active, Passive, Text, Date, (@saldo = @saldo - Active) as saldo
FROM F_AA_BalanceSheet
WHERE accountID = 4020 AND year(date) = year(getdate())
ORDER BY DATE DESC