Junior — Senior
SQL query to retrieve employee IDs with a salary below 30,000 and a departed manager
livecode
Task condition
You need to write an SQL query that returns the identifiers of employees whose salary is strictly less than 30000, and their direct manager no longer works at the company. When an employee is dismissed, their record is deleted from the Employees table, but the manager_id value for subordinates is preserved.
Table: Employees
+--------------+--------+
| Column Name | Type |
+--------------+--------+
| employee_id | int |
| name | varchar|
| manager_id | int |
| salary | int |
+--------------+--------+
The employee_id field is the primary key. Some records have manager_id as NULL, indicating no manager. The result table should have two columns (employee_id, salary), ordered by employee_id.