日期:2014-05-16 浏览次数:20972 次
with t as ( select '1' id,'0' pid from dual union all select '2' id,'1' pid from dual union all select '3' id,'1' pid from dual union all select '4' id,'3' pid from dual union all select '5' id,'1' pid from dual union all select '6' id,'2' pid from dual ) select t.id, (select count(1) from t tt start with tt.pid = t.id connect by prior tt.id = tt.pid) from t
------解决方案--------------------
为什么有两个5?我觉得2楼是对的。