My database "Films" contains columns: name, year (1980-2015) and rating of the film (1-10). I would like to get the BEST FILM from EVERY year like:
The Beutiful Mind 2001 rating: 8.2
Catch Me If You Can 2002 rating: 8.0
I only can think how to do it in multiple queries like:
SELECT *
FROM movies
WHERE year = 2001
ORDER BY imdb_rating DESC
LIMIT 1;
SELECT *
FROM movies
WHERE year = 2002
ORDER BY imdb_rating DESC
LIMIT 1;
etc.
How can i achieve it in one query in SQL? What's the best way? Or maybe there is no problem with multiple queries in this case? Thanks for help :)
limitso I removed it as a tag.