Badge awarded # by Badge-Name and Badge-Type for UserID


Please login or register to vote for this query.

(click on this box to dismiss)

Physical Fitness Meta

Q&A for physical fitness professionals, athletes, trainers, and those providing health-related needs

-- insert your user id here:
declare @uid int = 7505395

-- get all badges
select Name, Date, [Gold/Silver/Else], [Row#] from ( 
  SELECT Name, 
         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# 
  FROM badges
  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

Enter Parameters

Switch sites:
loading Hold tight while we fetch your results