ID employee department manager ---------------------------------------------- 1 Suresh c++ NULL 2 Suresh c++ NUll 3 Suresh c++ 2 5 Sarathy testing 2 6 Rajaraman c# 1 7 joe Flash 1
I have the employee detail table ,In that i want to find the manager for each employee . The employee name and manager column are present in same table
If you take the normal Oracle Employee (emp) table which consists of columns such as Employee Number (EMPNO) and Manager Number (MGR) then the query to find managers for all the employee is:
select e.ename as Employee, m.ename as Manager from emp e, emp m where e.MGR = m.EMPNO
If you take the normal Oracle Employee (emp) table which consists of columns such as Employee Number (EMPNO) and Manager Number (MGR) then the query to find managers for all the employee is:
select e.ename as Employee, m.ename as Manager from emp e, emp m where e.MGR = m.EMPNO
The code below retrieves the manager name. Note that employees who do not have manger is also listed. Select
Emp1.Employee_Id,
Emp1.first_name,
Emp1.last_name,
Emp1.Manager_id,
Emp2.first_name as "Manager_First",
Emp2.last_name as "Manager_Last"
from
employees emp1, employees emp2
where
emp1.manager_id = emp2.employee_id(+)
order by emp2.employee_id
Find manager for employee
----------------------------------------------
1 Suresh c++ NULL
2 Suresh c++ NUll
3 Suresh c++ 2
5 Sarathy testing 2
6 Rajaraman c# 1
7 joe Flash 1
I have the employee detail table ,In that i want to find the manager for each employee .
The employee name and manager column are present in same table
Questions by rajaramanv
Editorial / Best Answer
mktiwaryIf you take the normal Oracle Employee (emp) table which consists of columns such as Employee Number (EMPNO) and Manager Number (MGR) then the query to find managers for all the employee is:
select e.ename as Employee, m.ename as Manager from emp e, emp m
where e.MGR = m.EMPNO
Related Answered Questions
Related Open Questions