And of course, I finally figured out a MySQL only solution
Code:
SELECT sid, count, @i := @i + 1 as rank
FROM (
SELECT sid, COUNT(*) as count
FROM rank_posts
GROUP BY sid
ORDER BY count DESC
) user_counts, (select @i := 0) row_number
I had to make
Code:
SELECT sid, COUNT(*) as count
FROM rank_posts
GROUP BY sid
ORDER BY count DESC
a derived table because otherwise the rank was not in the right order, it was writing the rank before the ORDER BY was performed. Making it a derived table, I could order the data first, then write the rank.
Bookmarks