Click here to monitor SSC
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in
Home       Members    Calendar    Who's On

Add to briefcase

Fill Result Table with Sale Brackets Expand / Collapse
Posted Wednesday, February 6, 2013 3:20 AM


Group: General Forum Members
Last Login: Wednesday, March 30, 2016 6:04 AM
Points: 131, Visits: 215
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