question 5

0

Please login or register to vote for this query.

(click on this box to dismiss)

IT Security Meta

Q&A about the site for information security professionals

SELECT DisplayName AS UserName, EnlightenedBadges
FROM (
    SELECT Users.DisplayName, Badges.Name, COUNT(*) AS EnlightenedBadges,
           ROW_NUMBER() OVER (ORDER BY COUNT(*) DESC) AS BadgeRank
    FROM Badges
    JOIN Users ON Badges.UserId = Users.Id
    WHERE Users.Location = 'South Africa'
    AND Badges.Name = 'Enlightened'
    AND YEAR(Badges.Date) = 2016
    GROUP BY Users.DisplayName, Badges.Name
) AS RankedBadges
WHERE BadgeRank = 1;

Enter Parameters

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