I have a regular query lets say:
SELECT user, points FROM results ORDER BY points DESC
so I get:
From this I want to get a particular users 'rank' or row number from
the query. I was hoping for a single line elegant query for this.
I thought of this:
SET @i = O;
SELECT @i:= @i + 1 as row, SUM(IF(user = 'steve',@i,0)) as rank, user
FROM points ORDER BY points DESC GROUP BY id;
but I get:
which does not really help me
Any ideas? I tried the manual, Google and the list with no sucsess.