Users with highest reputation and no gold badge

1

Please login or register to vote for this query.

(click on this box to dismiss)

Role-playing Games

Q&A for gamemasters and players of tabletop, paper-and-pencil role-playing games

;with badges_cte AS (
SELECT 
  UserId AS uid,
  sum(case when class = 1 then 1 else 0 end) AS gold,
  sum(case when class = 2 then 1 else 0 end) AS silver,
  sum(case when class = 3 then 1 else 0 end) AS bronze,
  count(Id) AS total
FROM Badges
GROUP BY UserId
)

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

Enter Parameters

Options:
Switch to meta site
loading Hold tight while we fetch your results