SELECT AVG(rating) FROM ratings WHERE ratings.movie_id = (SELECT id FROM movies where movies.year = 2012);
It doesnt seem to print anything.
CS50 Stack Exchange is a question and answer site for students of Harvard University's CS50. It only takes a minute to sign up.Sign up to join this community
You did the hardest part, now it needs just one little improvement. If you write "ratings.movie_id = " program takes just one match. You should use "ratings.movie_id IN ", and then program takes all matches. Hope it helps. With code below output is 6.27545924967655
SELECT AVG(rating) FROM ratings WHERE movie_id IN (SELECT id FROM movies where movies.year = 2012)