Jump to content

query help


a2bardeals

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?
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.