Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Query to update balances
Message
From
22/12/2019 15:32:05
 
 
To
All
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Title:
Query to update balances
Miscellaneous
Thread ID:
01672403
Message ID:
01672403
Views:
51
I thought this would have been easy, but I got stuck multiple times and don't know if I am on the right track.

I have a table with forwarded balances. The balances can be edited, so the forwarding should correct mistakes, but starting from a certain point. So I cannot make a total sum.

Item Year Run Amount Balancepre Balancepost
100 2019 1 100 1000 1100
100 2019 2 100 1100 1200
100 2019 4 50 1200 1250
100 2019 5 100 0 0

So in run #5 it got off, and I want to recalculate balances starting from the first run in 2019.
So I thought I need to select the first all except the first occurrences of year 2019 and then add the sum amounts with lower run numbers. But I got stuck with the syntax. I also wonder if both balances can be updated at once, balancepre and balancepost, or I need to create two separate updates.
I would be glad to get any hint as to how I should approach this query.
Christian Isberner
Software Consultant
Next
Reply
Map
View

Click here to load this message in the networking platform