I would like to randomly insert in a new temp_table the records from the Initial Table below, grouping them by a new PO number (1234-1, 1234-2,etc..) where each group sum(TK
The logic of the 1234-1, 1234-2, etc is to break the records into groups that represent a carton. If the order has 100 line items, I may need n cartons (n groups) to pack all the items.
It's probably a job for a cursor.
The algorithm could basically be like this:
sum(TKG)
and sum(TVOL)
:
But I'm too lazy at the moment to give out the actual code, besides it's a homework, and cursors hate me anyway.