Advertisement
Mary_99

lab5

Nov 5th, 2019
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 1.87 KB | None | 0 0
  1. --get full details of employees, their number itp and also dep number, location etc
  2. SELECT emp_no, emp_fname, emp_lname, department.dept_no, department.location, department.dept_name
  3. FROM employee
  4. JOIN department
  5. ON employee.dept_no=department.dept_no
  6.  
  7. --------------------------------------------
  8. --get full details of all employees who work on the project Gemini
  9. SELECT *
  10. FROM employee
  11. JOIN works_on
  12. ON employee.emp_no=works_on.emp_no
  13. JOIN project
  14. ON works_on.project_no=project.project_no
  15. WHERE project.project_name='Gemini'
  16.  
  17. ---------------------------------------------
  18. --get the dept number of all employees that entered their ptojects on 15 October 2007
  19. SELECT department.dept_no
  20. FROM department
  21. JOIN employee
  22. ON department.dept_no=employee.dept_no
  23. JOIN works_on
  24. ON employee.emp_no=works_on.emp_no
  25. WHERE enter_date='2007-10-15'
  26.  
  27. ---------------------------------------------
  28. --get the first and last names of all analysts whose dep is located in Settle
  29. SELECT emp_lname, emp_fname
  30. FROM employee
  31. JOIN works_on
  32. ON employee.emp_no=works_on.emp_no
  33.  
  34. JOIN department
  35. ON employee.dept_no=department.dept_no
  36. WHERE works_on.job= 'analyst'
  37. AND department.location='Seattle'
  38.  
  39. ---------------------------------------------
  40. --get the names of projects(with reduntant duplicated eliminated) being worked on by employees in the Accounting dep
  41. SELECT DISTINCT project_name
  42. FROM project
  43. JOIN works_on
  44. ON project.project_no=works_on.project_no
  45. JOIN employee
  46. ON works_on.emp_no=employee.emp_no
  47. JOIN department
  48. ON employee.dept_no=department.dept_no
  49. WHERE dept_name='accounting'
  50.  
  51. ---------------------------------------------
  52. --get full details of employee and dep info where the domicle of an employee aphabetically
  53. --precedes the location of the dep where he works
  54. SELECT *
  55. FROM employee
  56. JOIN department
  57. ON employee.dept_no=department.dept_no
  58. WHERE city>location
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement