Skip to content
Advertisement

Find the top of the Hierarchy

I have the following table: employees

I am trying to show x 1 is the top manager for a, b and c, even tho a 1 is b 2’s manager and b 2 is c 3’s manager. This is the what I am trying to accomplish:

The code I have tried

Advertisement

Answer

Using recursive CTE:

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement