Advertisement
Guest User

SQL Assignment

a guest
Jun 7th, 2019
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PL/SQL 1.96 KB | None | 0 0
  1. -- 3.1
  2. SELECT title, director
  3. FROM movie m
  4. WHERE m.director IN (
  5.     SELECT a.*
  6.     FROM movie m, TABLE(m.actors) a
  7. )
  8. /
  9. -- 3.2
  10. SELECT title, director, genre
  11. FROM movie m, TABLE(m.actors) a
  12. WHERE a.column_value = 'Kevin Spacey'
  13. /
  14. -- 3.3
  15. SELECT l.movie_ref.title AS movie, session_date, session_time
  16. FROM listing l
  17. WHERE l.session_date = '14.06.19'
  18. AND l.cinema_ref.name = 'Cinema Paris'
  19. /
  20. -- 3.4
  21. SELECT l.cinema_ref.name AS cinema, session_date, session_time
  22. FROM listing l
  23. WHERE l.movie_ref.title = 'American Beauty'
  24. /
  25. -- 3.5
  26. SELECT r.reviewer, r.score
  27. FROM movie m, TABLE(m.reviews) r
  28. WHERE m.title = 'American Beauty'
  29. AND r.score = (
  30.     SELECT MIN(r.score)
  31.     FROM movie m, TABLE(m.reviews) r
  32.     WHERE m.title = 'American Beauty'
  33. )
  34. /
  35. -- 3.6
  36. SELECT l.movie_ref.title AS movie, l.cinema_ref.name AS cinema, l.session_date
  37. FROM listing l, listing l2
  38. WHERE l.cinema_ref.name = l2.cinema_ref.name
  39. AND l.session_date = l2.session_date
  40. AND l.movie_ref.title = l2.movie_ref.title
  41. GROUP BY l.movie_ref.title, l.cinema_ref.name, l.session_date
  42. ORDER BY l.movie_ref.title, l.session_date, l.cinema_ref.name
  43. /
  44. -- 3.7
  45. SELECT m.title
  46. FROM movie m
  47. WHERE m.title NOT IN (
  48.     SELECT l.movie_ref.title
  49.     FROM listing l
  50.     GROUP BY l.movie_ref.title
  51. )
  52. /
  53. -- 3.8
  54. SELECT m.title, a.column_value AS actor
  55. FROM movie m, TABLE(m.actors) a
  56. WHERE a.column_value IN (
  57.     SELECT a.column_value
  58.     FROM movie m, TABLE(m.actors) a
  59.     GROUP BY a.column_value
  60.     HAVING COUNT(*) > 1
  61. )
  62. /
  63. -- 3.9
  64. SELECT title, AVG(r.score) AS average_score
  65. FROM movie m, TABLE(m.reviews) r
  66. GROUP BY m.title
  67. HAVING AVG(r.score) IN (
  68.     SELECT MAX(AVG(r.score))
  69.     FROM movie m, TABLE(m.reviews) r
  70.     GROUP BY m.title
  71. )
  72. /
  73. -- 3.10
  74. SELECT a.column_value AS actor, COUNT(*) AS number_of_movies
  75. FROM movie m, TABLE(m.actors) a
  76. GROUP BY a.column_value
  77. HAVING COUNT(*) IN (
  78.     SELECT MAX(COUNT(*))
  79.     FROM movie m, TABLE(m.actors) a
  80.     GROUP BY a.column_value
  81. )
  82. /
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement