日期:2014-05-17 浏览次数:21983 次
select seq, name, substr(nam,2,nvl(instr(nam,'/',2)-2,length(nam))) name1, (case when lv < 3 then null else substr(nam,instr(nam,'/',1,lv - 1) + 1,instr(nam,'/',1,lv) - instr(nam,'/',1,lv - 1) - 1) end) name2 from (select m.*, level lv, SYS_CONNECT_BY_PATH(name, '/') nam, CONNECT_BY_ROOT parent_seq seq1 from m connect by prior seq = parent_seq) where seq1 is null order by seq;
select seq, name, substr(nam,2,nvl(instr(nam,'/',2)-2,length(nam))) name1, (case when lv < 3 then null else substr(nam,instr(nam,'/',1,lv - 1) + 1,instr(nam,'/',1,lv) - instr(nam,'/',1,lv - 1) - 1) end) name2 from (select m.*, level lv, to_clob(SYS_CONNECT_BY_PATH(name, '/')) nam, CONNECT_BY_ROOT parent_seq seq1 from m connect by prior seq = parent_seq) where seq1 is null order by seq;