[snip]
Not wanting to reinvent the wheel here, I wonder if anyone else has ever
done a rating system.

There'll be two columns: title_id for the title of the movie being rated and
then a rating from one to ten.

What would be the most efficient SQL statement to find a title's weighted
average?
[/snip]

What do you mean by weighted? Taking into account the number of votes for
each and then weighting them against each other?

To do an average you would do the following;

SELECT title_id, AVG(rating)
FROM movie
GROUP BY title_id

To do a weighted average as above where number of votes count;

SELECT title_id, (AVG(rating) / COUNT(title_id)) AS weighted
FROM movie
GROUP BY title_id

HTH!

Jay




---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to