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 CTEs
Processing graphs with recursive CTEs
Summary

## Instruction

Great job! Let's get back to our original query, which show the path from the boss to every employee. We can modify it in a few different ways to retrieve other information.

## Exercise

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

Now, add another column (named distance) to the template query. This will show the 'distance' for each employee.

### Stuck? Here's a hint!

Simply add a new column in the CTE. It will be equal to 0 for the boss; add one in each step.