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.Id IN (34, 22, 28, 25, 37, 41, 70, 53, 52, 160, 207, 208, 185, 65, 54, 76) THEN 1 ELSE 0 END) AS [Gold],
  SUM(CASE WHEN Badges.Id IN (33, 21, 27, 19, 15, 18, 24, 17, 69, 40, 39, 51, 138, 13, 140, 32, 169, 12, 157, 119, 173, 11, 75) THEN 1 ELSE 0 END) AS [Silver],
  SUM(CASE WHEN Badges.Id IN (64, 68, 61, 20, 26, 62, 10, 2, 38, 23, 126, 14, 1, 9, 31, 50, 131, 130, 8, 4, 7, 184, 35, 3, 158, 5, 36, 155, 118, 6, 150, 73, 147, 163, 74) 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