Reverse the LEVEL in Hierarchical query
671451Sep 29 2011 — edited Sep 29 2011Hi,
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