Created
May 15, 2019 09:11
-
-
Save arbaieffendi/49f9a206e1b4c9ffccb848dc42c62de3 to your computer and use it in GitHub Desktop.
Write a query that selects the names of employees who are not managers.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT name | |
FROM employees | |
WHERE id | |
NOT IN (SELECT managerId FROM employees WHERE managerId IS NOT null) |
please someone tell me why this doesn't work?
SELECT name
FROM employees
WHERE id
NOT IN (SELECT DISTINCT(managerId) FROM employees)
select e.name
from employees as e
left join employees as m
on e.id = m.managerId
where m.managerId is null
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Very helpful!