detox1978
asked on
MySQL count query help
Hi All,
I have a MySQL table where users have rated movies 1-5. I want to get a summary of how man 1,2,3,4 & 5's they have voted for.
I can get the answer for a single rating, below
Is it possible to get them all at in one go?
I have a MySQL table where users have rated movies 1-5. I want to get a summary of how man 1,2,3,4 & 5's they have voted for.
I can get the answer for a single rating, below
SELECT COUNT(rating) AS "1 Star" FROM user_likes WHERE user_id=2 AND rating=1
Is it possible to get them all at in one go?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
select count(rating) AS NumofVotes, rating
from user_likes WHERE user_id=2
group by rating
order by rating desc
ASKER