Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Query to update balances
Message
 
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
Query to update balances
Divers
Thread ID:
01672403
Message ID:
01672403
Vues:
53
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform