I have an SQL query that looks like:
SELECT member_id, Count(*) AS '# of Rounds'
FROM score,cup_point
WHERE session_id =?
AND tour_id =?
AND cup_point_id = `cup_point`.id
GROUP BY member_id
ORDER BY Sum(points) DESC
LIMIT 50 offset 0
How do I include the ranking in my query so that:
- I get a return column with a number based on the score i.e.
SUM(points)
, so the highest score would have a ranking of 1, etc. - When paginating using the offset and limit, or even when I filter by member id, I still get the correct ranking for that member (
member_id
) ?
Thanks.