I am trying to start export on a system that only allows t-sql. I know enough php to make a foreach loop, but I don't know enough t-sql to generate multiple rows for a given amount. I need a result to make a list of items with "1 of 4", like the data included in the result
given type table
orderid, product, quantity 1000,ball,3 1001,bike,4 1002,hat,2
how to get the result of selecting a query, for example:
orderid, item_num, total_items, Product
1000,1,3 ball
1000,2,3 ball
1000,3,3 ball
1001,1,4, bike
1001,2,4, bike
1001,3,4, bike
1001,4,4, bike
1002,1,2 hat
1002,2,2 hat
source share