oracle - Not sure how to write connect by clause -
i have following query find employees not managers in emp table of oracle
select * emp e1 not exists (select null emp e2 e2.mgr=e1.empno)
i need output using start connect clause , avoiding self join
there function, connect_by_isleaf(), indicates whether given row in hierarchical query leaf node. in emp table, employees not managers leaf nodes.
so, can use function in nested hierarchical query filter non-managers:
select empno, mgr, ename ( select empno, mgr, ename, connect_by_isleaf cbi emp start mgr null connect prior empno = mgr ) cbi = 1 /
oracle has several neat functions interrogating hierarchies. find out more.
Comments
Post a Comment