I have a table called 'points' that has a field 'total' which contains the total points for a record. Now I would like to calculate the rank of a specific record.
So like: SELECT (...) as rank FROM points WHERE id=63
Is this possible in SQL?
I have a table called 'points' that has a field 'total' which contains the total points for a record. Now I would like to calculate the rank of a specific record.
So like: SELECT (...) as rank FROM points WHERE id=63
Is this possible in SQL?
SET @rownum := 0;
SELECT rank, total FROM (
SELECT @rownum := @rownum + 1 AS rank, total, id
FROM points ORDER BY total DESC
) as result WHERE id=63