oracle 字符以“,”拆分列转行

select a, b, c
  from ( with test as (select 'aaa' a, 'bbb' b, '1,2,3' c from dual)
 
         select a,
                b,
                substr(t.ca,
                       instr(t.ca, ',', 1, c.lv) + 1,
                       instr(t.ca, ',', 1, c.lv + 1) -
                       (instr(t.ca, ',', 1, c.lv) + 1)) AS c
           from (select a,
                        b,
                        ',' || c || ',' AS ca,
                        length(c || ',') - nvl(length(REPLACE(c, ',')), 0) AS cnt
                   FROM test) t,
                (select LEVEL lv from dual CONNECT BY LEVEL <= 100) c
          where c.lv <= t.cnt)  

你可能感兴趣的:(oracle)