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:

sql fiddle

select prior id_emp_no    my_table    connect_by_isleaf = 1   start id_emp_no = 11 connect prior my_mgr = id_emp_no 

results:

| priorid_emp_no | ------------------ |             55 | 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -