I have written the query for 6.sql but it does not work.
SELECT AVG(rating) FROM ratings WHERE movie_id = (SELECT id FROM movies WHERE year = 2012);
I can do this by using JOIN
SELECT AVG(rating) FROM ratings JOIN movies ON movies.id = ratings.movie_id WHERE year = 2012;
But still I want to know why nested query doesnot work.