Skip to content
Advertisement

Split column value by semicolon into individual rows based on another column’s value

I need to generate rows based on the quantity value.

The barcode column will have value separate by semicolon “;” I want to turn each separated value into individual column.

If the barcode value is less than the quantity, other rows of barcode column will be null. The barcode value will not be more than the quantity.

Expected Output:

Example data

Advertisement

Answer

If you have more than one source row to split at once, a connect-by approach needs conditions to prevent cross matches; so you can do:

As you are on 11g, and assuming that is 11gR2, You could also use a recursive CTE:

db<>fiddle

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement