commit 96cd6902aed35f56bb94e696a1f750495e114e72 parent d198454f34a268b9ad3993235797e04165e1ec23 Author: AndrewLockVI <andrewlaack1@gmail.com> Date: Sun, 16 Jul 2023 17:38:50 -0500 Completed employees missing information using sql Diffstat:
| A | employees-with-missing-information/with-missing-info.sql | | | 19 | +++++++++++++++++++ |
1 file changed, 19 insertions(+), 0 deletions(-)
diff --git a/employees-with-missing-information/with-missing-info.sql b/employees-with-missing-information/with-missing-info.sql @@ -0,0 +1,19 @@ +--Given a list of employees +--return all employees that +--are either missing their employee name +--or salary +SELECT employee_id +FROM ( + SELECT COALESCE(Employees.employee_id, Salaries.employee_id) AS employee_id + FROM Employees + LEFT JOIN Salaries ON Employees.employee_id = Salaries.employee_id + WHERE Salaries.salary IS NULL + + UNION + + SELECT COALESCE(Employees.employee_id, Salaries.employee_id) AS employee_id + FROM Employees + RIGHT JOIN Salaries ON Employees.employee_id = Salaries.employee_id + WHERE Employees.name IS NULL +) AS subquery +ORDER BY employee_id ASC;