We have list of resources with their managers (not the complete hierarchy). We now need to retrieve the resource list such that resource's manager row should always appear before the resource row. I already tried hierarchical query, however given the data set, I'm not absolutely sure, if it's working correctly or not. Any pointers or clue, please to confirm the order?
Edit: Added last row in the data set and the query doesn't seem to be working anymore.
select level, emp, mgr
from emp
where level = 1
connect by prior emp = mgr -- and level = 1
Data Set
Emp | Mgr ----------- A11 | A1 A12 | A1 B1 | B C12 | C1 A1 | A C1 | C C21 | C2 A | C
Expected ordered result set
Emp | Mgr ----------- A | C A1 | A A11 | A1 A12 | A1 B1 | B C1 | C C12 | C1 C21 | C2