Badges, with award times, for a given user


Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

-- UserId: User ID     "Enter a user's ID."
SELECT      u.Id     AS [User Link]
            , CASE
                WHEN b.Tagbased = 1 THEN 'Tag: [' + b.Name + ']'
                ELSE b.Name
            END    AS [Badge name]
            , CASE
                WHEN b.Class = 1 THEN 'Gold'
                WHEN b.Class = 2 THEN 'Silver'
                WHEN b.Class = 3 THEN 'Bronze'
                ELSE '*Unkown*'
            END    AS [Class]
            , b.Date AS [Awarded]
FROM        Badges b
LEFT JOIN   Users u  ON u.Id = b.Userid
WHERE       b.Userid = ##UserId:int##
ORDER  BY   u.Displayname
            , [Awarded] DESC

Enter Parameters

Switch sites:
loading Hold tight while we fetch your results