SQL exercises on movie Database: Compute a report which shows the year when most of the Mystery movies produces, and number of such movies and their average rating
SQL movie Database: Join Exercise-23 with Solution
23. Write a query in SQL to generate a report which shows the year when most of the Mystery movies produces, and number of movies and their average rating.
Sample table: movie
Sample table: genres
Sample table: movie_genres
Sample table: rating
SELECT mov_year,gen_title,count(gen_title), avg(rev_stars) FROM movie NATURAL JOIN movie_genres NATURAL JOIN genres NATURAL JOIN rating WHERE gen_title='Mystery' GROUP BY mov_year,gen_title;
mov_year | gen_title | count | avg ----------+----------------------+-------+-------------------- 1958 | Mystery | 1 | 8.4000000000000000 (1 row)
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: Write a query in SQL to find the highest-rated Mystery movie, and report the title, year, and rating.
Next: Write a query in SQL to generate a report which contain the columns movie title, name of the female actor, year of the movie, role, movie genres, the director, date of release, and rating of that movie.
What is the difficulty level of this exercise?