Users with at least n gold badges

1

Please login or register to vote for this query.

(click on this box to dismiss)

Open Data

Q&A for developers and researchers interested in open data

;with tagbadges_cte AS (
SELECT
  b.UserId AS uid,
  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 = Name
GROUP BY UserId
)

SELECT TOP(##num?100##)
  u.Id As [User Link],
  u.Reputation,
  b.gold, b.silver, b.bronze
FROM tagbadges_cte b INNER JOIN Users u ON b.uid=u.Id
WHERE (gold>=##min?5##)
ORDER BY gold DESC,silver DESC,bronze DESC

Enter Parameters

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