Jump to content

Archived

This topic is now archived and is closed to further replies.

a2bardeals

query help

Recommended Posts

i am trying to create a top ten script for a MySQL ratings system
the query works near perfectly but with one flaw. it wont put the damn things in order.
it returns only ten of the highest rated.
it groups the individual ratings from all cells where the article #'s are the same and averages them.
but the ORDER BY doesn't seem to be working how i would like it to.

query looks like this:
mysql_query("SELECT article, AVG(rate) FROM ratings GROUP BY article ORDER BY rate DESC LIMIT 10");


i belive my problem is in the order by becuase it doesn't order by the average rating and when i try:

mysql_query("SELECT article, AVG(rate) FROM ratings GROUP BY article ORDER BY avg(rate) DESC LIMIT 10");

i get errors.

any ideas?

Share this post


Link to post
Share on other sites
Try: SELECT article, AVG(rate) [b]as rate[/b] FROM ratings GROUP BY article ORDER BY rate DESC LIMIT 10

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.