Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
1. How many people work in Sales?
SELECT
count(*)
FROM
employee e
INNER JOIN
department d
ON e.department = d.id
WHERE
e.department='Sales'
2. List the names of all employees assigned to the 'Plan Christmas party' project.
SELECT
e.emp_name as Full_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'
3. List the names of employees from the Warehouse department that are assigned to the 'Watch paint dry' project.
SELECT
e.emp_name as Full_Name
FROM
employee e
INNER JOIN
department d
ON e.department = d.id
JOIN
employee_project ep
ON e.id = ep.emp_id
JOIN
project p
ON ep.project_id = p.id
WHERE
p.project_name='Watch paint dry' && e.department='Warehouse'
4. Which projects are the Sales department employees assigned to?
SELECT
e.emp_name as Full_Name
ep.project_name
FROM
employee e
INNER JOIN
department d
ON e.department = d.id
JOIN
employee_project ep
ON e.id = ep.emp_id
WHERE
e.department='Sales'
5.List only the managers that are assigned to the 'Watch paint dry' project.
SELECT
e.emp_name as Full_Name
FROM
department
JOIN
employee
ON department.manager = employee.id
JOIN
employe_project ep
ON employee.id = ep.emp_id
JOIN
project p
ON ep.project_id = p.id
WHERE
p.project_name='Watch paint dry'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.