Compute hierarchy level of each employee with SQL
Filed under Mastek
The question
Given an Employee table with ManagerID, write SQL giving each employee's depth from the root (root is 0).
No write-up yet. Related questions below have one.
Related Mastek questions
Collected from public candidate posts and coding forums. Updated Nov 2026.