Hi all,
I have a table with a self join, basically an employee is managed by an employee..
Using the following query, i'm able to query the data, giving a kind of hierarchical output, this tells me who manages who...
SELECT LPAD(' ', 5* level) || empno
FROM employee
CONNECT BY prior empno = mgr
START WITH mgr is null;
This produces the following output...
SQL> SELECT LPAD(' ', 5* level) || ep_emp_id
2 FROM employee_on_project
3 CONNECT BY prior ep_emp_id = ep_mgr_emp_id
4 START WITH ep_mgr_emp_id is null;
LPAD('',5*LEVEL)||EP_EMP_ID
----------------------------------------------------------------------------------------------------
c1
c2
c4
c5
c6
c3
c7
7 rows selected.
My question is, how can I edit the query to output only employees at the top of the hierarchy, i.e. only top managers.
Any idea's guys??
Cheers!