forum.venkateswarlu.net
      Register      Login
Hieraacy maangers level output requires

1 replies to this topic

Aisha Bobby #1
Member
96 Points
Posted on 10 Nov 2014 12:06 PM IST

Hi to all,

EmployeeTable Column names:-

ManagerID
EmployeeID

Output:-

SuperiorManagerID           EmployeeID
105                                 101
105                                 102
105                                 103
101                                 102
101                                 103

the output required as above

Here using only one table as EmployeeTable in SQL

Regards
Aisha
 
SQL Server     793 views     Reply to this topic
Cherukuri Venkateswarlu #2
Member
140 Points
Replied on 10 Nov 2014 12:32 PM IST In this case you can use Self Join - means joining the EmployeeTable table EmployeeTable.

I hope below query will helps you...

SELECT A.EmployeeID, ISNULL(B.EmployeeID,0) AS SuperiorManagerID
FROM EmployeeTable A 
LEFT JOIN EmployeeTable B ON A.ManagerID = B.EmployeeID

Venkat
 
Reply to this topic