Coding Test

Leetcode - 1270. All People Report to the Given Manager

Indo Yoon

Problem

LeetCode - The World’s Leading Online Programming Learning Platform
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.

Solution

SELECT E1.employee_id
FROM Employees AS E1, Employees AS E2, Employees AS E3
WHERE 
    E1.manager_id = E2.employee_id AND
    E2.manager_id = E3.employee_id AND
    E3.manager_id = 1 AND e1.employee_id != 1