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!

Employee manager hierarchy Query

user8564931May 18 2017 — edited May 18 2017

Hi,

I am trying to achieve the below requirement written the query like below

if i passed employee number then i need to get the final manager (ex. if i passed 00116 then i am looking 00334 as the manager, 00116 employee mgr have next next mgr).  I am able to achieve that requirement with the below query, when i added the status also its traversing and giving result but it should not show traverse if the status is null

My requirement is if the status is A then only it need to be traverse and show the last manager details otherwise it should be anything, but in the below query it is not happening.

Emp      MGR   status

00008   00302    A

00116   00112   

00112   00223    A

00223   00334    A

I have the data like below in a table

SELECT empno

FROM employees where status='A'

WHERE CONNECT_BY_ISLEAF = 1

START WITH empno = 00116

CONNECT BY empno = PRIOR mgr;

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 15 2017
Added on May 18 2017
15 comments
3,328 views