递归写法参考
--遞歸參考寫法
--建立測試表數據
with temp as(
select 0 as flevel, 'a' fparent,'b' fchild,3 fqty from dual
union all select 0,'a','c',1 from dual
union all select 0,'c','d',4 from dual
union all select 0,'b','e',1 from dual
union all select 0,'b','f',4 from dual
union all select 0,'e','h',2 from dual
union all select 0,'h','k',2 from dual)
--遞歸運用
select length(SYS_CONNECT_BY_PATH('', '1')) AS flevel,SYS_CONNECT_BY_PATH(fparent,'\') as fparent,fchild,fqty from temp
start with fchild='e' or fchild='c'
CONNECT BY PRIOR fchild=fparent ;
--運行結果:
轉載于:https://www.cnblogs.com/star-studio/p/6073603.html
總結
- 上一篇: 你们知道哪家品牌的奶茶比较好喝?
- 下一篇: Arrays和Collection之间的