Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- How many people work in the Sales department?
- SELECT COUNT(*)
- FROM
- employee e
- INNER JOIN
- department d ON e.department = d.id
- WHERE d.dept_name = 'Sales';
- List the names of all employees assigned to the 'Plan Christmas party' project
- SELECT e.emp_name as Employee_Name, p.project_name
- FROM
- employee e
- INNER JOIN
- employee_project ep ON e.id = ep.emp_id
- INNER JOIN
- project p ON p.id = ep.project_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 e.emp_name as Employee_Name, p.project_name
- FROM
- employee e
- INNER JOIN
- department d ON d.id = e.department
- INNER JOIN
- employee_project ep ON e.id = ep.emp_id
- INNER JOIN
- project p ON p.id = ep.project_id
- WHERE p.project_name = 'Watch paint dry' AND d.dept_name = 'Warehouse';
- Which projects are the Sales department employees assigned to?
- SELECT p.project_name
- FROM
- employee e
- INNER JOIN
- department d ON d.id = e.department
- INNER JOIN
- employee_project ep ON e.id = ep.emp_id
- INNER JOIN
- project p ON p.id = ep.project_id
- WHERE d.dept_name = 'Sales';
- List only the managers that are assigned to the 'Watch paint dry' project.
- SELECT e.emp_name as Employee_Name, p.project_name
- FROM
- employee e
- INNER JOIN
- department d ON d.manager = e.id
- INNER JOIN
- employee_project ep ON e.id = ep.emp_id
- INNER JOIN
- project p ON p.id = ep.project_id
- WHERE p.project_name = 'Watch paint dry';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement