Select statement using Hierarchy
Posted on 2014-03-17
I want to write a query(I think I can use SYS_CONNECT_BY_PATH) to get the managers of a person that is being queried. I would pass in the employee_id and they have a field "at_reports_to" that has their managers employee_id, then I would like to keep going and get their managers manager and so on....My co-worker said he tried this and didnt end up finishing this and he sent me this and it doesnt work so any help would be appreciated...
SYS_CONNECT_BY_PATH(at_first_name || ' ' || at_last_name, '/')
FROM MYTABLE WHERE
CONNECT_BY_ROOT at_user =upper(12345)
CONNECT BY PRIOR at_user = at_reports_to;
The field at_reports_to holds the employee id of the person’s manager