Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
The very basics
Infinite looping
Processing trees with recursive CTE
Processing graphs with recursive CTE
Summary

Instruction

Great job! Let's get back to our original query that shows paths from the boss to every employee, we can modify it in a few further examples to retrieve other information.

Exercise

Let's assume that 'distance' in our hierarchical company is the number of people from the Boss to that person. According to this definition, Boss will have a distance of 0, her direct subordinates: 1, their subordinates: 2 etc.

Now, add another column (name distance) to the template query which shows the distance for each employee.

Stuck? Here's a hint!

Simply add a new column in the CTE that will be equal to 0 for the Boss, and add one in each step.