Wednesday, 8 July 2015

Comma Separated string requirement

SELECT TRIM(SUBSTR (txt, INSTR (txt, ',', 1, level ) + 1, INSTR (txt, ',', 1, level+1) - INSTR (txt, ',', 1, level) -1)) as issue_risk_rating
  FROM ( select ','||question||',' as TXT from qst a )
    CONNECT BY level <= LENGTH(txt)-LENGTH(REPLACE(txt,',',''))-1  order by issue_risk_rating;


Example
========

q1,q3,q5,q2,q4,q6

output

q1
q2
q3
q4
q5
q6

No comments:

Post a Comment