Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL Server Select Processing order?
Message
From
06/03/2015 11:32:30
 
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2014
Application:
Web
Miscellaneous
Thread ID:
01616334
Message ID:
01616346
Views:
39
>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.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform