<aside> 💡

Project Overview:

This project demonstrates the ability to query and manipulate relational databases effectively by solving a real-world business problem. The objective was to identify employees with salaries below $30,000 whose managers have left the company, providing insights into the workforce structure.

</aside>


Problem Description:

The Employees table contains the following information:

Managers who leave the company have their records removed from the table. However, the employees they manage retain their manager_id, pointing to the removed manager.

The task was to find all employees:

The results were to be ordered by employee_id.


Solution:

The query utilizes SQL to identify the required employees by leveraging subqueries and filtering conditions:

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


Explanation:

  1. Salary Filter: