Tag every employee with their org depth
Compute the depth of every employee in the org hierarchy: the CEO is at depth 1, their direct reports at depth 2, their reports' reports at depth 3, and so on down the reporting tree. Show the employee's id, name, and depth in the hierarchy. Sort by depth, ties broken by id.
Expected output sample
This is what a correct answer looks like — its row count is its own, it doesn't have to match the schema tables.
| id | name | depth |
|---|---|---|
| 1 | CEO | 1 |
| 2 | CTO | 2 |
| 3 | CFO | 2 |
Sign in to see submission history
Sign inSign in to use AI Mentor
Sign in