WITH Employee AS ( SELECT 1 AS Emp_ID, 'Admin' AS Emp_Nam...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Korean Language

Q&A for linguists, teachers and students of the Korean language

WITH Employee AS
(
   SELECT 1 AS Emp_ID, 'Admin' AS Emp_Name, NULL AS Emp_Manager_ID
   UNION ALL SELECT 2, 'John', 1
   UNION ALL SELECT 3, 'Sam', 2
   UNION ALL SELECT 4, 'Mike', 2
   UNION ALL SELECT 5, 'Jeff', 4
   UNION ALL SELECT 6, 'Bem', 3
   UNION ALL SELECT 7, 'Vicky', 5
)
, Subordinates AS
(
   SELECT e.Emp_ID, e.Emp_Name, e.Emp_Manager_ID
   FROM Employee AS e
   WHERE e.Emp_Manager_ID = 1
   
   UNION ALL

   SELECT e.Emp_ID, e.Emp_Name, e.Emp_Manager_ID
   FROM Employee AS e
   INNER JOIN Subordinates AS sub ON e.Emp_Manager_ID = sub.Emp_ID
)
SELECT s.Emp_ID, s.Emp_Name, s.Emp_Manager_ID
FROM Subordinates AS s

Enter Parameters

Options:
Switch to meta site
loading Hold tight while we fetch your results