1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| with cte_w (id, stop_ids) as
(
select 1279, 'StopPoint:4:51,StopPoint:4:47,StopPoint:4:77,StopPoint:4:74,StopPoint:4:84,StopPoint:4:82,StopPoint:4:76'
from dual
union all
select 2729, 'StopPoint:4:55,StopPoint:4:40,StopPoint:4:32,StopPoint:4:34'
from dual
)
, cte_x (id, stopid, stop_ids) as
(
select id
, substr(stop_ids, 1, instr(stop_ids, ',') - 1)
, substr(stop_ids, instr(stop_ids, ',') + 1, length(stop_ids) - instr(stop_ids, ','))
from cte_w
union all
select id
, substr(stop_ids, 1, instr(stop_ids, ',') - 1)
, substr(stop_ids, instr(stop_ids, ',') + 1, length(stop_ids) - instr(stop_ids, ','))
from cte_x
where instr(stop_ids, ',') > 0
)
select id, stopid
from cte_x
union all
select id, stop_ids
from cte_x
where instr(stop_ids, ',') = 0; |
Partager