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!

Reverse the LEVEL in Hierarchical query

671451Sep 29 2011 — edited Sep 29 2011
Hi,
Whilw running the below query on EMP table I need the Level in reverse order for the hierarcy.

SELECT empno,
ename,
job,
mgr,
hiredate,
LEVEL,connect_by_isleaf
FROM emp
WHERE LEVEL <= 2
START WITH mgr IS NULL
CONNECT BY PRIOR empno = mgr
LEVEL
Result
-----------
1 7839 KING PRESIDENT Null 11/17/1981 1
2 7566 JONES MANAGER 7839 4/2/1981 2
3 7698 BLAKE MANAGER 7839 5/1/1981 2
4 7782 CLARK MANAGER 7839 6/9/1981 2

I want the level in reverse order like for row 1 it should be 2 and for the rest of three rows it should be 1.
Is there any function available in oracle ?

Thanks and Regards,
Guljeet
This post has been answered by Kim Berg Hansen on Sep 29 2011
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 27 2011
Added on Sep 29 2011
2 comments
3,548 views