oracle的split string

sqlcode
with tt asselect 1 id,'aaa,bb,ccc' str from dual
union all
select 2 id,'ddd,eee,fff,gggggg' str from dual
union
 all
select
 3 id,'hhh' str from dual
union
 all
select
 4 id,'iiii,gggggg,kkkkkk,llll,mmmm,nn,ooo' str from dual
union all
select
 5 id,'ppp,qqq' str from dual)
SELECT id,res FROM
    (
SELECT id, str, regexp_substr(str'[^,]+'1LEVEL) res, LEVEL lv, lag(LEVELover(PARTITION BY id ORDER BY LEVEL) lg   FROM tt t CONNECT BY regexp_substr(str'[^,]+'1LEVELIS NOT NULL)
WHERE
 lv != lg or lg is null 

posted @ 2009-11-27 14:32  bobocici  阅读(403)  评论(0编辑  收藏  举报