[snip]
I created a dummy table for this and used your select statement:
mysql> SELECT titleid, (AVG(rating) / COUNT(titleid)) AS weighted
-> FROM movieratings
-> GROUP BY titleid;
+---------+----------+
| titleid | weighted |
+---------+----------+
| 1 | 0.288000 |
| 9 | 0.072748 |
| 19 | 1.250000 |
| 21 | 1.800000 |
| 31 | 8.000000 |
| 199 | 1.000000 |
I think I put my slow brain in today...should I be using an order by?
Here's the same data showing the number of votes:
+---------+-------+----------+
| titleid | votes | weighted |
+---------+-------+----------+
| 1 | 25 | 0.288000 |
| 9 | 99 | 0.072748 |
| 19 | 8 | 1.250000 |
| 21 | 5 | 1.800000 |
| 31 | 1 | 8.000000 |
| 199 | 10 | 1.000000 |
+---------+-------+----------+
[/snip]
Yes, you should use an order by, ORDER BY weighted
HTH
Jay
sql, mysql, query
"Don�t worry, it only seems kinky the first time."
*************************************
* Want to meet other PHP developers *
* in your area? Check out: *
* http://php.meetup.com/ *
* No developer is an island ... *
*************************************
---------------------------------------------------------------------
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