I have a table with a column that contains several values โโseparated by a comma (,), and would like to split it so that I get the Earch site in my row, but with the same number in front.
So, my choice will be from this entrance
table Sitetable Number Site 952240 2-78,2-89 952423 2-78,2-83,8-34
Create this output
Number Site 952240 2-78 952240 2-89 952423 2-78 952423 2-83 952423 8-34
I found what I thought would work, but no.
select Number, substr( Site, instr(','||Site,',',1,seq), instr(','||Site||',',',',1,seq+1) - instr(','||Site,',',1,seq)-1) Site from Sitetable,(select level seq from dual connect by level <= 100) seqgen where instr(','||Site,',',1,seq+1) > 0
Edit2: I see that I actually had a piece of work that selects all the time (I was a crappy tester :() described above, but the only problem is that it loses the last value of the site, but I try to work a little on this occasion.
Edit3: Now its working
select Number, substr( Site, instr(','||Site,',',1,seq), instr(','||Site||',',',',1,seq+1) - instr(','||Site,',',1,seq)-1) Site from Sitetable,(select level seq from dual connect by level <= 100) seqgen where instr(','||Site,',',1,seq) > 0