Created
October 24, 2016 16:21
-
-
Save rosiecakes/1855439e92e397e75c99ad54de28b290 to your computer and use it in GitHub Desktop.
sql exercises
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DB: https://lagunita.stanford.edu/c4x/DB/SQL/asset/moviedata.html | |
For all cases where the same reviewer rated the same movie twice and gave it a higher rating the second time, return the reviewer's name and the title of the movie. | |
SELECT name, title | |
FROM movie, reviewer, | |
(SELECT rating1.rID, rating1.mID | |
FROM rating rating1, rating rating2 | |
WHERE rating1.rID = rating2.rID | |
AND rating1.mID = rating2.mID | |
AND rating1.stars < rating2.stars | |
AND rating1.ratingDate < rating2.ratingDate) selection | |
WHERE movie.mID = selection.mID | |
AND reviewer.rID = selection.rID; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment