Created
October 7, 2013 15:10
-
-
Save heluvaguy/6869580 to your computer and use it in GitHub Desktop.
Implement Rank in Mysql
This file contains 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
SELECT cm_id, | |
@rnk:=IF(@preval <=> column, @rnk, @rnk + 1) AS rank, | |
@preval:=social_profile_score_absolute AS social_profile_score_absolute | |
FROM table | |
JOIN (SELECT @rnk := 1, @preval :=0) r | |
ORDER BY social_profile_score_absolute ASC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment