How to get rank based on SUM's?

Posted by Kenan on Stack Overflow See other posts from Stack Overflow or by Kenan
Published on 2010-05-25T20:55:16Z Indexed on 2010/05/25 21:01 UTC
Read the original article Hit count: 290

Filed under:
|

I have comments table where everything is stored, and i have to SUM everything and add BEST ANSWER*10. I need rank for whole list, and how to show rank for specified user/ID.

Here is the SQL:

   SELECT m.member_id AS member_id, 
          (SUM(c.vote_value) + SUM(c.best)*10) AS total
     FROM comments c
LEFT JOIN members m ON c.author_id = m.member_id
 GROUP BY c.author_id
 ORDER BY total DESC
    LIMIT {$sql_start}, 20

© Stack Overflow or respective owner

Related posts about mysql

Related posts about rank