Is there a way to find users with a certain set of badges? (take 2)

1

Please login or register to vote for this query.

(click on this box to dismiss)

https://meta.stackoverflow.com/questions/362661/is-there-a-way-to-find-users-with-a-certain-set-of-badges

Stack Overflow

Q&A for professional and enthusiast programmers

select userid as [User Link]
     , reputation
     , [Steward]      -- which badges you want
     , [Unsung Hero]
from
(
  select userid         -- userid is our group
       , [Steward]      -- which badges you want
       , [Unsung Hero]
  from (
    select id
         , userid
         , name 
    from badges
    where tagbased = 0
  ) as data
  pivot 
  (
    count(data.id)          -- count the number of badges per user per badge
    for name in (
      [Steward],       -- which badges you want
      [Unsung Hero]
    ) 
  ) pvt
  where [Steward]     = 4  -- criteria for each badge
  and   [Unsung Hero] = 1
) main 
inner join users u on u.id = main.userid -- for reputation
order by displayname

Enter Parameters

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