SELECT uo.*,
(
SELECT COUNT(*)
FROM users ui
WHERE (ui.points, ui.id) >= (uo.points, uo.id)
) AS rank
FROM users uo
WHERE id = @id
Tät rang:
SELECT uo.*,
(
SELECT COUNT(DISTINCT ui.points)
FROM users ui
WHERE ui.points >= uo.points
) AS rank
FROM users uo
WHERE id = @id