SELECT *, RANK() OVER (ORDER BY cnt) as rank FROM ( SELECT user_id, COUNT(id) cnt FROM stackoverflow.badges WHERE creation_date::date BETWEEN '2008-11-15' AND '2008-12-16' GROUP BY user_id ) as ord ORDER BY cnt DESC, user_id LIMIT 10