日期:2014-05-17  浏览次数:20977 次

找出层次超过1的这递归层数据,求sql
SELECT A.wf_id,a.parentid,level,sys_connect_by_path(A.wf_id,'/') path
  FROM a
 START WITH A.PARENTID IS NULL
CONNECT BY PRIOR A.WF_ID = A.PARENTID


SZ_120604161301_3000 1 /SZ_120604161301_3000
SZ_120606095746_root 1 /SZ_120606095746_root
SZ_120606145252_3000 1 /SZ_120606145252_3000
SZ_120606150143_3000 1 /SZ_120606150143_3000
SZ_120606182414_root 1 /SZ_120606182414_root
SZ_120607170535_3000 1 /SZ_120607170535_3000
SZ_120608102517_3000 1 /SZ_120608102517_3000
SZ_120611172040_3000 1 /SZ_120611172040_3000
SZ_120611174615_3000 1 /SZ_120611174615_3000
SZ_120615105928_3000 1 /SZ_120615105928_3000
SZ_120617174458_3000 1 /SZ_120617174458_3000
SZ_120617174639_3000 SZ_120617174458_3000 2 /SZ_120617174458_3000/SZ_120617174639_3000
SZ_120617174932_3000 SZ_120617174639_3000 3 /SZ_120617174458_3000/SZ_120617174639_3000/SZ_120617174932_3000


我想要的数据是:
SZ_120617174458_3000 1 /SZ_120617174458_3000
SZ_120617174639_3000 SZ_120617174458_3000 2 /SZ_120617174458_3000/SZ_120617174639_3000
SZ_120617174932_3000 SZ_120617174639_3000 3 /SZ_120617174458_3000/SZ_120617174639_3000/SZ_120617174932_3000


请问高手们这个sql该咋写?

------解决方案--------------------
那就在2楼给的语句上再包一层。先判断level,如果大于1了,再重新拼接串