Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL Server Select Processing order?
Message
De
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:
01616346
Vues:
38
>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.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform