I’m working with Microsoft SQL
I have a table CR_INVLINES that shows something like below
STOCKCODE QTY BARCODE
GUITAR101 3 456812313
DESK 1 568123122
LAMP 2 845646962
What I need my view to return is the lines at the multiples of the qty like below:
STOCKCODE BARCODE
GUITAR101 456812313
GUITAR101 456812313
GUITAR101 456812313
DESK 568123122
LAMP 845646962
LAMP 845646962
You can use a recursive CTE to get the result:
See SQL Fiddle with Demo
This gives the result: