<aside> 💡
This project identifies employees with bonuses less than 1000 or no bonus at all. The task demonstrates the use of SQL joins, conditional filtering, and handling NULL values.
</aside>
NULL).empId in the Employee table).The objective is to find the name and bonus of employees whose bonus is less than 1000 or who do not have a bonus (NULL).
The query combines the Employee and Bonus tables using a LEFT JOIN to include all employees, even if they do not have a bonus, and filters the results based on the given conditions.
SELECT
Employee.name,
Bonus.bonus
FROM
Employee
LEFT JOIN
Bonus
ON
Employee.empId = Bonus.empId
WHERE
Bonus.bonus < 1000
OR Bonus.bonus IS NULL;
LEFT JOIN Bonus ON Employee.empId = Bonus.empId links the Employee table with the Bonus table, ensuring all employees are included, even those without bonuses.Bonus.bonus < 1000 includes employees with a bonus less than 1000.Bonus.bonus IS NULL includes employees with no bonus record in the Bonus table.Employee.name retrieves the employee name.Bonus.bonus retrieves the bonus amount (or NULL for employees without a bonus).Employee Table: