Q&A for professional and enthusiast programmers
SELECT DISTINCT (SELECT TOP 1 PERCENT Badges.UserID) AS User_Id, COUNT(Badges.Id) AS Badges, Users.Reputation FROM Badges JOIN Users ON Badges.UserId = Users.Id GROUP BY Badges.UserId, Users.Reputation ORDER BY Users.Reputation DESC;