You're managing a company's HR system with two important tables: Employee and Bonus. Your task is to find all employees who either received a small bonus (less than $1000) or no bonus at all.
This is a classic SQL problem that tests your understanding of LEFT JOIN operations and handling NULL values - essential skills for any database developer!
Given:
- Employee Table: Contains employee details (ID, name, supervisor, salary)
- Bonus Table: Contains bonus information (employee ID and bonus amount)
Goal: Return the name and bonus of employees who have bonus < 1000 OR no bonus entry.
Note: Some employees might not have any entry in the Bonus table, which should be treated as having no bonus.
Input & Output
Visualization
Time & Space Complexity
Single pass through both tables with efficient JOIN operation
Space for result set only, database handles JOIN efficiently
Constraints
- 1 โค Employee.empId โค 104
- 1 โค Employee.name.length โค 20
- 0 โค Bonus.bonus โค 106
- Employee.empId is unique
- Some employees may not have bonus entries