Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Self Join Question

Paul.VidalJun 13 2010 — edited Jun 13 2010
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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 11 2010
Added on Jun 13 2010
7 comments
4,259 views