I would like to rank my entries based on a total score column but I need to have ties if the scores are the same. The query below successfully ranks, but the rank goes up even if there is a tie.
Here is my current query:
SET @r=0; UPDATE table SET rank= @r:= (@r+1) WHERE `complete` = 1 ORDER BY score DESC;
I have been reading a ton of posts but haven’t found an explanation of doing this in an UPDATE.
+----+-----------+-------------+-------------+
| id | lName | score | rank |
+----+-----------+-------------+-------------+
| 1 | Rosebrock | 50 | 5 |
| 2 | Kolley | 58 | 3 |
| 3 | Bartley | 11 | 6 |
| 4 | Bell | 58 | 4 |
| 5 | Daugherty | 63 | 2 |
| 85 | Harp | 78 | 1 |
+----+-----------+-------------+-------------+
Same here: http://sqlfiddle.com/#!2/90c3b/2/0