0

I want to make a query that will display the largest number of movies rented by one member and it should also show the member's name.

This is what I have.

SELECT FIRST, LAST AS, COUNT(mm_rental.member_id) AS "MAXIMUM MOVIES"
FROM mm_member, mm_rental
WHERE mm_rental.member_id = mm_member.member_id;

But its not working. Can anyone please help?

2
  • Could you define not working? Commented Nov 4, 2013 at 2:49
  • It tells me that my "SELECT FIRST,LAST" is not a single-group group function. Commented Nov 4, 2013 at 2:52

1 Answer 1

2

Since COUNT is an aggregate function, you should use GROUP BY in your query.

And you should using JOIN syntax.

More : Please use ANSI join syntax

SELECT [FIRST], [LAST], COUNT(mm_rental.member_id) 
AS "MAXIMUM MOVIES" FROM mm_member JOIN mm_rental 
ON mm_rental.member_id = mm_member.member_id
group by [FIRST], [LAST];
Sign up to request clarification or add additional context in comments.

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.