Badge Counts by User

0

Please login or register to vote for this query.

(click on this box to dismiss)

The lists of badge IDs were obtained by running the following JavaScript on [site]/help/badges: (function(b,c){for(var a=0;a<b.length;++a)c[b[a][0]]=b[a].slice(1);return c})(["bronze","silver","gold"].map(function(b){var c=$(".badge-table a.badge").has("span.badge"+{bronze:3,silver:2,gold:1}[b]).map(function(){var a=$(this).attr("href").match(/\/help\/badges\/(\d+)/);return a?+a[1]:[]}).get();c.splice(0,0,b);return c}),{});

Stack Overflow

Q&A for professional and enthusiast programmers

SELECT
  UserId AS [User Link],
  SUM(CASE WHEN Badges.Class = 1 THEN 1 ELSE 0 END) AS [Gold],
  SUM(CASE WHEN Badges.Class = 2 THEN 1 ELSE 0 END) AS [Silver],
  SUM(CASE WHEN Badges.Class = 3 THEN 1 ELSE 0 END) AS [Bronze],
  COUNT(*) AS [Total],
  RANK() OVER (ORDER BY COUNT(*) DESC) AS [Rank]
FROM Badges
GROUP BY UserId
ORDER BY COUNT(*) DESC

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results