employee supervisor relationship help please [message #317639] |
Fri, 02 May 2008 04:56 ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
sunildatt_b
Messages: 3 Registered: May 2008
|
Junior Member |
|
|
question
========
Due to a recent re-organization, the company needs a query to show who supervises each employee. The output should be sorted first by supervisor name and then by employee name within that.
SELECT E.EMP_NUM EMPLOYEE,
E.EMP_FIRST EMPLOYYENAME,
K.EMP_FIRST SUPERVISORNAME,
E.SUPERVISOR_ID
FROM EMPLOYEE E
INNER JOIN(SELECT
SUPERVISOR_ID,EMP_FIRST
FROM
EMPLOYEE
GROUP BY
SUPERVISOR_ID,EMP_FIRST) K ON
K.SUPERVISOR_ID=E.EMP_NUM
the output that i got is
=============
EMPLOYEE EMPLOYYENAME SUPERVISORNAME SUPERVISOR_ID
===============================================
E1112 Samules KARNVEO E1113
E1112 Samules KERVIN E1113
E1113 Blaine Samules E1114
E1114 KERVIN Blaine E1112
but the output should be like
====================
EMPLOYEE EMPLOYYENAME SUPERVISORNAME SUPERVISOR_ID
===============================================
E1112 Samules blaine E1113
E1112 Samules blaine E1113
E1113 Blaine kervin E1114
E1114 KERVIN Samules E1112
can any one help me reagrding this please
|
|
|
|