SQL exercises on movie Database: Find all the years which produced at least one movie and that received a rating of more than 3 stars and the result should come in increasing order or year
SQL movie Database: Subquery Exercise-6 with Solution
6. Write a query in SQL to find all the years which produced at least one movie and that received a rating of more than 3 stars. Show the results in increasing order.
Sample table: movie
Sample table: rating
SELECT DISTINCT mov_year FROM movie WHERE mov_id IN ( SELECT mov_id FROM rating WHERE rev_stars>3) ORDER BY mov_year;
mov_year ---------- 1958 1961 1962 1977 1982 1986 1995 1997 1999 2001 2004 2008 2009 (13 rows)
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: Write a query in SQL to find the titles of all movies directed by the director whose first and last name are Woddy Allen.
Next: Write a query in SQL to find the titles of all movies that have no ratings.
What is the difficulty level of this exercise?