Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Query on Recursive Table (self-join)?

ni403411s5Jan 6 2005 — edited Jan 6 2005
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!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 3 2005
Added on Jan 6 2005
1 comment
698 views