Skip to content

Instantly share code, notes, and snippets.

@LIQRGV
Created January 9, 2020 01:59
Show Gist options
  • Save LIQRGV/d9d0674c968141fa12b03b2198001268 to your computer and use it in GitHub Desktop.
Save LIQRGV/d9d0674c968141fa12b03b2198001268 to your computer and use it in GitHub Desktop.
--The following data definition defines an organization's employee hierarchy.
--An employee is a manager if any other employee has their managerId set to the first employees id. An employee who is a manager may or may not also have a manager.
--TABLE employees
-- id INTEGER NOT NULL PRIMARY KEY
-- managerId INTEGER REFERENCES employees(id)
-- name VARCHAR(30) NOT NULL
--Write a query that selects the names of employees who are not managers.
--https://www.testdome.com/questions/sql/workers/13562?visibility=1&skillId=17
-- Write only the SQL statement that solves the problem and nothing else.
select name from employees where id not in (
select managerId from employees where managerId is not null
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment