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?