Created
November 11, 2019 17:20
-
-
Save just-Bri/a9d077290acb55aaaa39b2021f7130e3 to your computer and use it in GitHub Desktop.
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
-- How many people work in the Sales department ? | |
select | |
count(*) | |
from | |
employee | |
where | |
employee.department = 2; | |
-- List the names of all employees assigned | |
-- to the 'Plan Christmas party' project. | |
select | |
emp_name, | |
project_name | |
from | |
employee e | |
join employee_project ep on e.id = ep.emp_id | |
join project p on ep.project_id = p.id | |
where | |
p.project_name = 'Plan christmas party'; | |
-- List the names of employees from the | |
-- Warehouse department that are assigned | |
-- to the 'Watch paint dry' project. | |
select | |
emp_name, | |
project_name | |
from | |
employee | |
join employee_project on employee.id = employee_project.emp_id | |
join project on employee_project.project_id = project.id | |
join department on employee.department = department.id | |
where | |
department.id = 4 | |
AND project.id = 4; | |
-- Which projects are the Sales department | |
-- employees assigned to ? | |
select | |
distinct project_name | |
from | |
project | |
join employee_project on project.id = employee_project.project_id | |
join employee on employee_project.emp_id = employee.id | |
join department on employee.department = department.id | |
where | |
department.id = 2; | |
-- List only the managers that are | |
-- assigned to the 'Watch paint dry' project. | |
select | |
distinct emp_name | |
from | |
employee | |
join employee_project on employee_project.emp_id = employee.id | |
join project on employee_project.project_id = project.id | |
join department on employee.id = department.manager | |
where | |
project.id = 4; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment