Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Split 2 comma delimited columns and create rows

BeefStuMay 6 2022

I'm trying to produce the following output

col1    col2
aaa    qq
bbb    ww
ccc    ee

As you can see from my attempt I have hardcoded VALUES, which only produces one row.

I'm looking to get a count from both columns and iterate through the data. If the counts aren't the same for both columns then I want to use a NULL where the count is less and match it with a value.

Below is my simple attempt that is incomplete. Any help would be greatly appreciated.

select regexp_substr('aaa,bbb,ccc', '[^,]+', 1, 1) as col1, 
       regexp_substr('qq, ww, ee', '[^,]+', 1, 1) as col2 from dual
Comments
Post Details
Added on May 6 2022
1 comment
1,864 views