Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. How many people work in the Sales department?
  2.  
  3. SELECT COUNT(*)
  4. FROM
  5. employee e
  6. INNER JOIN
  7. department d ON e.department = d.id
  8. WHERE d.dept_name = 'Sales';
  9.  
  10. List the names of all employees assigned to the 'Plan Christmas party' project
  11.  
  12. SELECT e.emp_name as Employee_Name, p.project_name
  13. FROM
  14. employee e
  15. INNER JOIN
  16. employee_project ep ON e.id = ep.emp_id
  17. INNER JOIN
  18. project p ON p.id = ep.project_id
  19. WHERE p.project_name = 'Plan christmas party';
  20.  
  21. List the names of employees from the Warehouse department that are assigned to the 'Watch paint dry' project.
  22.  
  23. SELECT e.emp_name as Employee_Name, p.project_name
  24. FROM
  25. employee e
  26. INNER JOIN
  27. department d ON d.id = e.department
  28. INNER JOIN
  29. employee_project ep ON e.id = ep.emp_id
  30. INNER JOIN
  31. project p ON p.id = ep.project_id
  32. WHERE p.project_name = 'Watch paint dry' AND d.dept_name = 'Warehouse';
  33.  
  34. Which projects are the Sales department employees assigned to?
  35.  
  36. SELECT p.project_name
  37. FROM
  38. employee e
  39. INNER JOIN
  40. department d ON d.id = e.department
  41. INNER JOIN
  42. employee_project ep ON e.id = ep.emp_id
  43. INNER JOIN
  44. project p ON p.id = ep.project_id
  45. WHERE d.dept_name = 'Sales';
  46.  
  47. List only the managers that are assigned to the 'Watch paint dry' project.
  48.  
  49. SELECT e.emp_name as Employee_Name, p.project_name
  50. FROM
  51. employee e
  52. INNER JOIN
  53. department d ON d.manager = e.id
  54. INNER JOIN
  55. employee_project ep ON e.id = ep.emp_id
  56. INNER JOIN
  57. project p ON p.id = ep.project_id
  58. WHERE p.project_name = 'Watch paint dry';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement