Include Missing Bonuses and Bonuses below One Thousand
Quick Overview
Report each employee’s name and bonus when their bonus is below1000 or they received no bonus. A missing bonus is shown as NULL. Preserve employees without a Bonus row; result order is unrestricted.
Include Missing Bonuses and Bonuses below One Thousand
Company: Amazon
Role: Software Engineer
Category: Data Manipulation (SQL/Python)
Difficulty: easy
Interview Round: Other
### Problem
Report each employee’s name and bonus when their bonus is below 1000 or they received no bonus. A missing bonus is shown as NULL. An employee with a Bonus row whose amount is NULL also counts as having no bonus. Preserve employees without a Bonus row; result order is unrestricted.
### Tables
Table: `Employee`
```text
+-------------+---------+
| Column Name | Type |
+-------------+---------+
| empId | int |
| name | varchar |
| supervisor | int |
| salary | int |
+-------------+---------+
empId is the column with unique values for this table.
Each row of this table indicates the name and the ID of an employee in addition to their salary and the id of their manager.
```
Table: `Bonus`
```text
+-------------+------+
| Column Name | Type |
+-------------+------+
| empId | int |
| bonus | int |
+-------------+------+
empId is the column of unique values for this table.
empId is a foreign key (reference column) to empId from the Employee table.
Each row of this table contains the id of an employee and their respective bonus.
```
### Example
```text
Employee (empId,name,supervisor,salary): (1,Ada,NULL,3000), (2,Bo,1,2000), (3,Cam,1,2000), (4,Dee,1,2000)
Bonus (empId,bonus): (2,999), (3,1000), (4,1500)
Output (name,bonus): (Ada,NULL), (Bo,999)
```
### What a Strong Answer Covers
- Preserve employees with no recorded bonus amount and return NULL for their bonus.
- Apply the strict 1000 cutoff and return both requested columns.
### Follow-up Questions
- How would you report a missing bonus record separately from a recorded NULL amount?
- How would the result change if bonuses were stored as monthly records?
Overview: Report each employee’s name and bonus when their bonus is below1000 or they received no bonus. A missing bonus is shown as NULL. Preserve employees without a Bonus row; result order is unrestricted.
Report each employee’s name and bonus when their bonus is below 1000 or they received no bonus. A missing bonus is shown as NULL. An employee with a Bonus row whose amount is NULL also counts as having no bonus. Preserve employees without a Bonus row; result order is unrestricted.
Tables
Table: Employee
+-------------+---------+
| Column Name | Type |
+-------------+---------+
| empId | int |
| name | varchar |
| supervisor | int |
| salary | int |
+-------------+---------+
empId is the column with unique values for this table.
Each row of this table indicates the name and the ID of an employee in addition to their salary and the id of their manager.
Table: Bonus
+-------------+------+
| Column Name | Type |
+-------------+------+
| empId | int |
| bonus | int |
+-------------+------+
empId is the column of unique values for this table.
empId is a foreign key (reference column) to empId from the Employee table.
Each row of this table contains the id of an employee and their respective bonus.