查询一个树的所以叶子节点:

方法1:

select 'A',id,s_id, level from test
where connect_by_isleaf =1  //叶子节点
start with id = 'A' 
connect by prior s_id = id



//方法2:

select 'A', a.s_id from 
(
select * from test
start with id = 'A' 
connect by prior s_id = id
) a where not exists (select 1 from test t1 where t1.id = a.s_id )

 

posted on 2010-12-02 16:02  谁在我心上  阅读(126)  评论(0编辑  收藏  举报