Skip to content

Instantly share code, notes, and snippets.

@mirzalazuardi
Last active January 18, 2019 04:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mirzalazuardi/d5304ea03799953002c4b4dce19fb0f0 to your computer and use it in GitHub Desktop.
Save mirzalazuardi/d5304ea03799953002c4b4dce19fb0f0 to your computer and use it in GitHub Desktop.
SQL #1
-- Workers
-- 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.
SELECT *
FROM employees
WHERE id IN (SELECT id FROM employees WHERE managerId IS NULL)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment