Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Fill Result Table with Sale Brackets Expand / Collapse
Author
Message
Posted Wednesday, February 6, 2013 3:20 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Today @ 8:16 AM
Points: 111, Visits: 181
Hi there

I have a table of sales that has a ItemID, Quantity and Value of the sale.

Say for week 1, I have total sales of $100 000, I want to have a result of 5 brackets of $20 000 each to make up the total of $100 000. In essence, it took X amount of items to fill up the first $20K, Y amount to fill up the next $20K and so on.

I am busy creating a cursor that will loop through all the sales and create a result table with
bracket1, ItemID, Quantity
....
bracket5, ItemID, Quantity

It feels very cumbersome and was wondering if there isn't a quicker way?
Post #1416365
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse