oracle 利用level对部门进行等级层次划分

如下sql:

select a.*,level from adam_departments a start with a.p_dept_id = '0' connect by prior a.dept_id = a.p_dept_id;  
根节点的父id p_dept_id等于0,这样就可以将整个部门的等级层次以及归属查询出来。

另外看到了一个相当详细的关于level使用的文章:

ORACLE--Connect By、Level、Start With的使用(Hierarchical query-层次查询)

http://www.cnblogs.com/caroline/archive/2011/12/25/2301083.html


你可能感兴趣的:(oracle 利用level对部门进行等级层次划分)