Skip to content

Commit 1b85fc8

Browse files
authored
Update computedepth.sql
1 parent 441c007 commit 1b85fc8

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Mastek/computedepth.sql

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,14 @@
1+
-- MySQL solution
12

3+
WITH RECURSIVE cte AS (
4+
SELECT 1 AS lvl, ManagerID, EmployeeID
5+
FROM employees
6+
WHERE ManagerID IS NULL
7+
UNION ALL
8+
SELECT lvl + 1, employees.ManagerID, employees.EmployeeID
9+
FROM employees
10+
JOIN cte
11+
ON employees.ManagerID = cte.EmployeeID
12+
)
13+
SELECT *
14+
FROM cte;

0 commit comments

Comments
 (0)