Getting Ranked Position - SQL - Simple Query
If you are in version 8 (or above), you can use the RANK() function for this purpose:

SELECT
    id,
    average,
    RANK() OVER (ORDER BY average DESC) as rk
FROM
    t;


Note I've ordered the result by average DESC, that assigns rank=1 to the maximum average.



id | average | rk
-: | ------: | -:
 2 |      99 |  1
 1 |      79 |  2
 3 |      22 |  3



db&lt;>fiddle here