Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL Server Select Processing order?
Message
 
 
À
06/03/2015 11:32:30
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2014
Application:
Web
Divers
Thread ID:
01616334
Message ID:
01616347
Vues:
31
>>I will explain in words since I have a problem creating a sample SQL Select.
>>Say, I have TableA (structure as of example in my initial message).
>>Say, I have a TableB (a little different structure than TableA but very similar, for the purpose of this example).
>>I want to process records in TableA and, for each record in TableA, add a record in TableB. As I process I want to Count the total of field Quantity and when the total value of processed records Quantity field is greater or equal to some variable value, stop adding records to TableB.
>>And as I process records in TableA and adding records to TableB, I want to process "older" records First and then newer. So if the Total Quantity value (paragraph above) hits the "limit", the newer records of TableA are not processed.
>>
>>Does it make any sense? :)
>
>Yup - I sort of figured that you were trying to do a cumulative sum.
>
>As I type, I'm sure Naomi is typing up a code sample because I know there have been discussions on this topic many times. But if she doesn't have time to post one, I will.

Thank you.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform