SQL Interview Questions – Employees Whose Manager Left the Company

Spread the love

Problem Description –

Write an SQL query to report the IDs of the employees whose salary is strictly less than $30000 and whose manager left the company. When a manager leaves the company, their information is deleted from the Employees table, but the reports still have their manager_id set to the manager that left.

Return the result table ordered by employee_id.

The query result format is in the following example.

Problem Link – Manager Left

Difficulty Level – Easy

Solution –

SELECT employee_id FROM Employees
WHERE manager_id NOT IN (SELECT employee_id FROM Employees)
AND salary < 30000
ORDER BY employee_id;

Rating: 1 out of 5.

Leave a Reply