Q&A about the site for members of the workforce navigating the professional setting
SELECT TOP(##num?200##) b.UserId AS [User Link], sum(case when b.class = 1 then 1 else 0 end) AS gold, sum(case when b.class = 2 then 1 else 0 end) AS silver, sum(case when b.class = 3 then 1 else 0 end) AS bronze, count(b.Id) AS total FROM Badges b INNER JOIN tags t ON t.tagname=b.name GROUP BY b.UserId ORDER BY gold DESC, silver DESC, bronze DESC, total DESC