Each employee's level in the hierarchy
In the org chart emp (employee → manager via manager_id), compute each one's level: the topmost (no manager) is level 1, their reports are 2, and so on down. Return id and depth, ordered 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 | depth |
|---|---|
| 1 | 1 |
| 2 | 2 |
| 3 | 2 |
Sign in to see submission history
Sign inSign in to use AI Mentor
Sign in