I have a table `review` with column `rating` that holds a value of 1 to 5.
I need to show the number of votes for each rating. I tried:
The problem is I need to return a zero for any grouped rating with no records, eg:
Can anyone suggest how I can make sure that I always get 5 rows returned by such a query pls?
MTIA
Max Hugen
Australia
I need to show the number of votes for each rating. I tried:
Code:
SELECT
rating
, count(review_id) as rating_count
FROM
review
GROUP BY rating
ORDER BY rating DESC;
The problem is I need to return a zero for any grouped rating with no records, eg:
Code:
rating rating_count
5 0
4 8
3 3
2 1
1 0
Can anyone suggest how I can make sure that I always get 5 rows returned by such a query pls?
MTIA
Max Hugen
Australia