MarekMatias

QuearyProjekt

Mar 19th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 2.83 KB | None | 0 0
  1. /* Return all of the unique years in the movie table  */
  2. SELECT *  FROM movies
  3. ORDER BY YEAR ASC;
  4.  
  5.  
  6. /* Return all of the unique years in the movies table sorted from oldest to newest. */
  7. SELECT * FROM movies
  8. WHERE genre = 'drama';
  9.  
  10. /* Return all movies that are dramas. */
  11. SELECT * FROM movies
  12. WHERE name LIKE '%bride%';
  13.  
  14. /* retunere kun film fra year 2000 til 2015, de bliver s sorteret i descending order.   */
  15. SELECT * FROM movies
  16. WHERE YEAR
  17. BETWEEN 2000 AND 2015
  18. ORDER BY YEAR DESC;
  19.  
  20. /*retunere movies som er udgivet i 1995 eller har en imdb rating p 9.0  */
  21.  
  22. SELECT * FROM movies
  23. WHERE YEAR = 1995
  24. OR
  25. imdb_rating = 9;
  26.  
  27. /* retunere MAX 3 movies fra movies hvor at rating = 3    */
  28. SELECT * FROM movies
  29. WHERE imdb_rating = 7
  30. LIMIT 3;
  31.  
  32. /*retunere movies hvor at rating er > 6
  33. hvor at genre er comedy, er lavet efter year 1995
  34. Der retuneres max 10 */
  35.  
  36. SELECT *  FROM movies
  37. WHERE imdb_rating  > 6
  38. AND
  39. genre = 'comedy'
  40. AND
  41. YEAR > 1995
  42. ORDER BY imdb_rating DESC
  43. LIMIT 10;
  44.  
  45. /* retunere alle film som har prcis navnet "Cast Away"    */
  46. SELECT * FROM movies
  47. WHERE name = 'Cast Away';
  48.  
  49.  
  50. /* retunere alle film som IKKE har rating 7   */
  51. SELECT * FROM movies
  52. WHERE imdb_rating  != 7;
  53.  
  54.  
  55. /* Retunere alle horror movies med en drligere rating end 6 */
  56. SELECT * FROM  movies
  57. WHERE genre = 'horror'
  58. AND
  59. imdb_rating < 6;
  60.  
  61. /*retunere 10 movies hvor rating er 8 og sorteret med genre   */
  62. SELECT * FROM movies
  63. WHERE imdb_rating = 8
  64. ORDER BY genre  ASC
  65. LIMIT 10;
  66.  
  67.  
  68.  
  69.  
  70. /* retunere alle mobies hvor "king" er indeholdt  */
  71. SELECT * FROM movies
  72. WHERE name LIKE '%King%';
  73.  
  74. /* retunere alle movies hvor at Out er det sidste ord.  */
  75. SELECT * FROM movies
  76. WHERE name LIKE '%Out';
  77.  
  78. /*Return all the movies with name that begin with the word "The" sorted by imdb rating from highest to lowest  */
  79. SELECT * FROM movies
  80. WHERE name LIKE 'The%'
  81. ORDER BY imdb_rating DESC;
  82.  
  83. /* Return all of the movies   */
  84. SELECT * FROM movies;
  85.  
  86. /* Return the name and id of each movie with an id greater than 125  */
  87. SELECT DISTINCT name  FROM movies
  88. WHERE id > 125;
  89.  
  90. /*Return all movies names that begin with 'X-Men' */
  91. SELECT * FROM movies
  92. WHERE name LIKE'X-Men%';
  93.  
  94. /*Return the first 10 movies sorted in reverse alphabetical order  */
  95. SELECT * FROM movies
  96. WHERE id  < 11
  97. ORDER BY name DESC;
  98.  
  99. /*Return the id, name and genre of all movies that are romances   */
  100. SELECT DISTINCT id, name, genre FROM movies
  101. WHERE genre = 'romance';
  102.  
  103. /*Return all of the Twilight movies in order from the year they were released from oldest to newest */
  104. SELECT * FROM movies
  105. WHERE name LIKE '%Twilight%'
  106. ORDER BY YEAR ASC;
  107.  
  108. /*Return all of the movies that were released in 2012 that are comedies  */
  109. SELECT * FROM movies
  110. WHERE YEAR = 2012
  111. AND
  112. genre  = 'comedy';
Add Comment
Please, Sign In to add comment