/*
	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.
*/




-- create a table
CREATE TABLE employees (
      id INTEGER NOT NULL PRIMARY KEY,
	  managerId INTEGER REFERENCES employees(id),
	  name VARCHAR(30) NOT NULL
);
-- insert some values
INSERT INTO employees VALUES (1, NULL, 'ManGun');
INSERT INTO employees VALUES (2, 1, 'Joanna');
INSERT INTO employees VALUES (3, 1, 'ManRyan');
INSERT INTO employees VALUES (4, 3,'Sla');


SELECT  distinct a.Id  FROM employees a INNER JOIN employees b ON a.id = b.managerid;



--mangers 
SELECT  * FROM employees  where id in (SELECT  distinct a.Id  FROM employees a INNER JOIN employees b ON a.id = b.managerid);

--not managers 
SELECT  * FROM employees  where id not in (SELECT  distinct a.Id  FROM employees a INNER JOIN employees b ON a.id = b.managerid);

-- SELECT name
-- FROM employees
-- WHERE id NOT IN (
-- 		SELECT a.Id
-- 		FROM employees a
-- 		INNER JOIN employees b ON a.id = b.managerid
-- 		)

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: