577 Employee Bonus

table of content

577 Employee Bonus

To find employees with a bonus less than 1000, we need to consider cases where an employee has no bonus at all.

Approach

  1. Perform a LEFT JOIN:
    • We join Employee and Bonus tables using empID:
    FROM Employee AS e
    LEFT JOIN Bonus AS b
    ON e.empID = b.empID
    
    • Since Employee contains all employees, the LEFT JOIN ensures that employees without a corresponding Bonus record will have NULL values in the Bonus column.
  2. Apply filtering condition:
    • We need to select employees where the bonus is either below 1000 or does not exist (NULL):
    WHERE b.bonus < 1000 OR b.bonus IS NULL
    

Conclusion

This ensures that we correctly filter out all employees whose bonus is either below 1000 or who have no bonus at all.img