0

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
4
  • 5
    please add some sample table data and the expected result - as well in formatted text. Commented Mar 17, 2017 at 9:08
  • what is the error? Can paste the table structure of DVD and BorrowDVD table please.... Commented Mar 17, 2017 at 9:37
  • I added the pictures of the table Commented Mar 17, 2017 at 11:08
  • Please read meta.stackoverflow.com/questions/285551/… and the accepted answer Commented Mar 17, 2017 at 11:23

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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. 

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.