Reputation: 3
The question is to Produce a list of the top 3 most popular movies for a given genre for the current month.
How to find the top 3 most popular movies??
select DVD.Genre, DVD.MovieTitle, BorrowDVD.Ratings
from DVD join BorrowDVD
ON DVD.DVDID = BorrowDVD.DVDID
WHERE DVD.Genre = Animation
Upvotes: 0
Views: 69
Reputation: 2315
Put single quotes around the word animation:
WHERE DVD.Genre = 'Animation'
SQL thinks Animation is a column, putting quotes around it shows that it is a string to match.
Upvotes: 1
Reputation: 4192
Use ROW_NUMBER
method and get top 3 most popular movies :
SELECT *
FROM
(
SELECT * , ROW_NUMBER() OVER(PARTITION BY Movie_type) RNo
FROM your_tablename
) WHERE RNo <= 3 -- AND your_another WHERE conditions.
Upvotes: 0