You have two tables: Employees and Salaries. The Employees table contains employee IDs and names, while the Salaries table contains employee IDs and their corresponding salaries.
Write a SQL query to find all employees with missing information. An employee has missing information if either:
- The employee's name is missing (exists in Salaries but not in Employees), or
- The employee's salary is missing (exists in Employees but not in Salaries)
Return the result ordered by employee_id in ascending order.
Table Schema
| Column Name | Type | Description |
|---|---|---|
employee_id
PK
|
int | Unique identifier for each employee |
name
|
varchar | Employee's name |
| Column Name | Type | Description |
|---|---|---|
employee_id
PK
|
int | Unique identifier for each employee |
salary
|
int | Employee's salary amount |
Input & Output
| employee_id | name |
|---|---|
| 2 | Crew |
| 4 | Haven |
| 5 | Kristian |
| employee_id | salary |
|---|---|
| 5 | 76071 |
| 1 | 22517 |
| 4 | 63539 |
| employee_id |
|---|
| 1 |
| 2 |
Employee 1 has a salary (22517) but no name record in the Employees table. Employee 2 has a name (Crew) but no salary record in the Salaries table. Employees 4 and 5 have both name and salary, so they are not included in the result.
| employee_id | name |
|---|---|
| 1 | John |
| 2 | Jane |
| employee_id | salary |
|---|
| employee_id |
|---|
| 1 |
| 2 |
Both employees have names but no salary records exist in the Salaries table, so both employee IDs are returned as having missing information.
| employee_id | name |
|---|---|
| 1 | Alice |
| 2 | Bob |
| employee_id | salary |
|---|---|
| 1 | 50000 |
| 2 | 60000 |
| employee_id |
|---|
All employees have both name and salary information, so no employee IDs are returned as the result is empty.
Constraints
-
1 ≤ employee_id ≤ 10^6 -
nameconsists of uppercase and lowercase English letters -
1 ≤ salary ≤ 10^6