Top badge counts

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

SELECT * FROM
(SELECT TOP 10 
   'Gold' AS [Type],
   UserId AS [User Link],
   Count(*) as [Count]
FROM Badges
WHERE Class=1
GROUP BY UserId
ORDER BY [Count] DESC
) g

UNION ALL
SELECT * FROM (
SELECT TOP 10 
   'Silver' AS [Type],
   UserId AS [User Link],
   Count(*) as [Count]
FROM Badges
WHERE Class=2
GROUP BY UserId
ORDER BY [Count] DESC
) s
UNION ALL
SELECT * FROM (
SELECT TOP 10 
   'Bronze' AS [Type],
   UserId AS [User Link],
   Count(*) as [Count]
FROM Badges
WHERE Class=3
GROUP BY UserId
ORDER BY [Count] DESC
) b

Enter Parameters

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