Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 self join

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2000-11-14 : 19:12:02
ms. flanagan writes "I have a text book question, however your answer could help complete my query at work :-).

Here is the question.

Table : Employee.
Column1: EmployeeNumber
Column2: EmployeeName
Column3: ManagerNumber (this is same as Employee Number).

I would like to find all the manager levels for a specific employee.

Ex Data: 1, Joe, 2
2, Boss1, 3
3, Boss2, 4
4, Boss3

For EmployeeNumber : 1, I should see all four records above.

I started with the query below, but how can qualify (in other words, would like to see managers for one specific employee), the outer query ?

select *
from Employee a
where exists
(select * from Employee b
where b.EmployeeNumber = a.ManagerNumber)

Thanks,
Ms. Flanagan"
   

- Advertisement -