sql - Oracle Hierarchical Query Record prior to Max Level Record -
i have following oracle sql query:
select id_emp_no, level, connect_by_isleaf isleaf my_table start id_emp_no = :x connect prior my_mgr = id_emp_no order level
this produces following output:
id_emp_no level isleaf 11 1 0 22 2 0 33 3 0 44 4 0 55 5 0 <<==== 66 6 1
based on above output, actual result id_emp_no after id_emp_no = 55, record preceeding max level , record prior isleaf equalling 1
so want return record id_emp_no = 55.
any on above appreciated.
thanks.
keep in mind prior
nothing operator specifying value of column upper level of hierarchy, means can use (almost) anywhere in query:
select prior id_emp_no my_table connect_by_isleaf = 1 start id_emp_no = 11 connect prior my_mgr = id_emp_no
| priorid_emp_no | ------------------ | 55 |
Comments
Post a Comment