SHARE
TWEET

BazyDanych

a guest Dec 8th, 2019 103 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 6.1.2
  2. a)
  3. SELECT department_id, department_name, location_id, city
  4. FROM departments JOIN locations USING(location_id)
  5. b)
  6. SELECT d.department_id, d.department_name, l.location_id, l.city
  7. FROM departments d JOIN locations l ON(d.location_id=l.location_id)
  8. c)
  9. SELECT d.department_id, d.department_name, l.location_id, l.city
  10. FROM departments d, locations l
  11. WHERE d.location_id=l.location_id
  12.  
  13. 6.1.3
  14.  
  15. a)
  16. SELECT department_id, department_name, location_id, city
  17. FROM departments JOIN locations USING(location_id)
  18. WHERE department_id IN(20,50)
  19. b)
  20. SELECT d.department_id, d.department_name, l.location_id, l.city
  21. FROM departments d JOIN locations l ON(d.location_id=l.location_id)
  22. WHERE d.department_id IN(20,50)
  23. c)
  24. SELECT d.department_id, d.department_name, l.location_id, l.city
  25. FROM departments d, locations l
  26. WHERE d.location_id=l.location_id AND d.department_id IN (20,50)
  27.  
  28. 6.2.1.
  29. a)
  30. SELECT d.department_id, d.department_name, l.location_id, l.city
  31. FROM departments d JOIN locations l ON(d.location_id=l.location_id)
  32. WHERE d.location_id=1400
  33. b)
  34. SELECT d.department_id, d.department_name, l.location_id, l.city
  35. FROM departments d, locations l
  36. WHERE d.location_id=l.location_id AND d.location_id=1400
  37.  
  38. 6.2.2.
  39. a)
  40. SELECT pli.song_id, tl.cd_number, cds.title, pli.comments
  41. FROM d_play_list_items pli JOIN d_track_listings tl ON(pli.song_id=tl.song_id) JOIN d_cds cds ON(tl.cd_number=cds.cd_number)
  42. b)
  43. SELECT pli.song_id, tl.cd_number, cds.title, pli.comments
  44. FROM d_play_list_items pli, d_track_listings tl, d_cds cds
  45. WHERE pli.song_id=tl.song_id AND tl.cd_number=cds.cd_number
  46.  
  47. 6.2.4.
  48. a)
  49. SELECT c.country_name, r.region_id, r.region_name
  50. FROM countries c JOIN regions r ON(c.region_id=r.region_id)
  51. WHERE r.region_name='Americas'
  52. b)
  53. SELECT c.country_name, r.region_id, r.region_name
  54. FROM countries c, regions r
  55. WHERE c.region_id=r.region_id AND r.region_name='Americas'
  56.  
  57. 6.2.5.
  58. a)
  59. SELECT e.first_name, e.last_name, e.hire_date, j.job_id, j.job_title, j.max_salary
  60. FROM employees e JOIN jobs j ON(e.job_id=j.job_id)
  61. WHERE j.max_salary>12000
  62. b)
  63. SELECT e.first_name, e.last_name, e.hire_date, j.job_id, j.job_title, j.max_salary
  64. FROM employees e, jobs j
  65. WHERE e.job_id=j.job_id AND j.max_salary>12000
  66.  
  67. 6.2.8
  68. SELECT l.location_id, l.city, d.department_name
  69. FROM locations l, departments d
  70. WHERE l.location_id=d.location_id AND l.country_id='CA'
  71.  
  72. 6.2.9
  73. SELECT d.manager_id, d.department_id, d.department_name, e.first_name, e.last_name
  74. FROM departments d, employees e
  75. WHERE d.department_id=e.department_id AND d.department_id IN(80,90,110,190)
  76.  
  77. 6.2.10
  78. a)
  79. SELECT employee_id, last_name, department_id, department_name, hire_date
  80. FROM departments JOIN employees USING(department_id)
  81. WHERE hire_date='07-Jun-1994'
  82. b)
  83. SELECT e.employee_id, e.last_name, d.department_id, d.department_name, e.hire_date
  84. FROM departments d JOIN employees e ON(d.department_id=e.department_id)
  85. WHERE e.hire_date='07-Jun-1994'
  86. c)
  87. SELECT e.employee_id, e.last_name, d.department_id, d.department_name, e.hire_date
  88. FROM departments d, employees e
  89. WHERE d.department_id=e.department_id AND e.hire_date='07-Jun-1994'
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top