April 1, 2008 at 10:12 am
Hi All,
Following are the schema details
EMPLOYEE( #EmpId, Ename, Salary, #ManagerId(EmpId), #DeptId)
DEPERTMENT (#DeptId, DeptName, #DeptHead(EmpId))
SELECT Employee Name, Manager Name, Department name, Department Head Name for all employees, with out using three instances of EMPLOYEE table.
can anybody help me out in this. At least tell me is it possible or not.
below is the query that i tried.
SELECT
E1.Ename, E2.Ename AS [MgrName], T.DeptName, T.Ename AS [Dept Head Name]
FROM Employee E1
INNER JOIN ( SELECT D.DeptId, D.DeptName, E.Ename FROM Department D INNER JOIN Employee E ON E.EmpId = D.DeptHead) AS T
ON T.DeptId = E1.DeptId
LEFT JOIN Employee E2
ON E2.EmpId = E1.ManagerId
Regards
Enbee
Regards | Enbee
April 1, 2008 at 10:30 am
Please continue this thread here: http://www.sqlservercentral.com/Forums/Topic477835-338-1.aspx
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply