I want to calculate rank using MySQL. I have a table called result
result_id test_id exam_id user_id percentage
1 5 6 50 57
2 5 6 58 76
3 5 6 65 42
I want to calculate the rank of the user according to his user_id and test_id like user_id(58) has 1 rank user_id(50) has 2 and so on
I tried query like
select percentage from result where test_id=$test_id(i.e 5) and user_id=$user_id(i.e 58)
but it gives 76 and doesn't give the rank
I also tried
select percentage from result where test_id=$test_id(i.e 5)
but it gives me 57,76,42
Is there any way by which I can calculate the rank of the user?