I have the following data:
enrtryid categoryid score
1 1 90.5
2 1 90.5
3 1 89
4 2 70
5 2 69
6 3 78
I desire following result:
enrtryid categoryid score rank
1 1 90.5 1
2 1 90.5 1
3 1 89 2
4 2 70 1
5 2 69 2
6 3 78 1
I have tried using the query
SELECT t1.*, (SELECT COUNT(*) FROM overalltally t2 WHERE t2.score> t1.score) +1
AS rank
FROM overalltally t1
ORDER BY `rank` ASC
though it ranks all the results sequentially as I don't know where I should place the GROUP BY statement