Q&A about the site for physical fitness professionals, athletes, trainers, and those providing health-related needs
Select Top 10 '1Gold' As Label, UserId As [User Link], Count(*) As Num From (Select UserId From Badges Where Name In (Select TagName from Tags) Group By UserId, Name Having Count(*)=3) d Group By UserId union all Select Top 10 '2Gold' As Label, UserId As [User Link], Count(*) As Num From (Select UserId From Badges Where Name In (Select TagName from Tags) Group By UserId, Name Having Count(*)=2) d Group By UserId union all Select Top 10 '3Bronze' As Label, UserId As [User Link], Count(*) As Num From (Select UserId From Badges Where Name In (Select TagName from Tags) Group By UserId, Name Having Count(*)=1) d Group By UserId Order By Label, Num Desc