Created
March 25, 2011 11:48
-
-
Save FrancisVarga/886746 to your computer and use it in GitHub Desktop.
Generate User highscore
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SET @rownum =0; | |
SET @rank =0; | |
SET @prev_val=0; | |
SELECT @rownum := @rownum + 1 AS row | |
, @rank := IF(@prev_val!=uxp,@rownum,@rank) AS rank | |
, @prev_val := uxp AS uxp, | |
userId | |
FROM | |
( | |
SELECT userId, SUM(score) as uxp | |
FROM highscore_game | |
GROUP BY userId | |
ORDER BY uxp DESC | |
) AS t | |
ORDER | |
BY uxp desc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How To Use with Zend
Thx to xris