3

I have the data in the following format in table.

ORDER_ID   PRODUCT_ID   QUANTITY
O1          A1           3

I need to write the sql query to divide the data into following format:

ORDER_ID   PRODUCT_ID   QUANTITY
O1          A1           1
O1          A1           1
O1          A1           1

Query should split the data based on the Value in quantity column.

Thanks

1 Answer 1

3

Please try:

SELECT
  ORDER_ID, 
  PRODUCT_ID, 
  1 QUANTITY 
from 
  dual LEFT JOIN YourTable T on 1=1
connect by level <= T.Quantity
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.