Self Join Question
Specifically the question is from the oracle fundamentals 1 for sql ...
Lesson 5 , Question 4 and 5
4- Create a report to display employees’ last name and employee number along with their manager’s last name and manager number. Label the columns Employee, Emp#, Manager, and Mgr#, respectively. Place your SQL statement in a text file named lab_05_04.sql.
This below select do the work...
SELECT e.last_name Employee, e.employee_id EMP#, m.last_name, e.manager_id Mgr#
FROM employees e JOIN employees m
ON (e.manager_id = m.employee_id )
----------------------------------------------------------------------------------------------------------------------
The Question 5 says
5- Modify lab_05_04.sql to display all employees including King, who has no manager. Order the results by the employee number. Place your SQL statement in a text file named lab_05_05.sql. Run the query in lab_05_05.sql
So i modified like this ..
SELECT e.last_name Employee, e.employee_id EMP#, m.last_name, e.manager_id Mgr#
FROM employees e JOIN employees m
ON (e.manager_id = m.employee_id )
WHERE m.manager_id is null
But King do not appear in the last_name colunm ..
Any help...
Paul Vidal