manager Vs Emp

Database

manager Vs Emp

Hi All,

I have data like this.

empno      mgr

1               2

2               3

3               5

4               6

5               7

8               2

I want result like this:-

empno  column1 column2 column3 column4

1             2          3             5            7

2            3          5             7

3            5         7

4            6

5            7

8             2        3               5           7

Regards,

Abhilash

1 REPLY

Re: manager Vs Emp

Hi,

You must  know the maximum depth of that hierarchy.

let us say in this case an employee can have maximum 4 mangers(Max depth of hierarchy) above him.

Then you do a self join 3 times (Left outer join) and can get your required output.