Q&A for professional and enthusiast programmers
-- insert your user id here:
declare @uid int = 7505395
-- get all badges
select * from (
case when class = 1 then 'Gold'
when class = 2 then 'Silver'
when class = 3 then 'Bronze'
else convert(varchar(10), class)
end as 'Gold/Silver/Else',
ROW_NUMBER() OVER(PARTITION BY name, class ORDER BY date ASC) AS Row#
WHERE 1 = 1
-- you can restrict this further, f.e. for looking only by gold badges
-- and Class = 1 -- gold == 1, silver == 2, bronze == 3
-- -- or for certain named badges
-- and name like 'python%'
) as tmp
where userID = @uid
ORDER by name asc, Date asc