Get top rated item using AVG mysql
Posted
by
user1876234
on Stack Overflow
See other posts from Stack Overflow
or by user1876234
Published on 2013-10-26T09:44:57Z
Indexed on
2013/10/26
9:53 UTC
Read the original article
Hit count: 130
mysql
I want to find top rated item using AVG function in mysql, right now my query looks like this:
SELECT a.title, AVG(d.rating) as rating FROM in8ku_content a
JOIN in8ku_content_ratings d ON a.id = d.article_id
ORDER BY rating DESC
Problem is that it takes AVG of all items and the result is not accurate, what should be changed here to get correct result ?
Tables:
in8ku_content [id, title] in8ku_content_ratings [id, article_id, rating]
© Stack Overflow or respective owner