Search Users by Number of Badges

3

Please login or register to vote for this query.

(click on this box to dismiss)

Ask Ubuntu

Q&A for Ubuntu users and developers

declare @BadgeName nvarchar(50) = ##BadgeName:string##;
declare @MyTop int = ##TopUsers:int##;

select
    top(@MyTop)
    Badges.UserId as [User Link],
    Users.Reputation,
    count(Badges.Id) as NumberOfBadges
  from 
      Badges 
    inner join 
      Users On Users.Id=Badges.UserId
  where 
      Badges.Name = @BadgeName and
      Users.Reputation > 10000
  group by 
      Badges.UserId, Users.Reputation
  order by 
      NumberOfBadges desc, Reputation desc

Enter Parameters

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