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

0

Please login or register to vote for this query.

(click on this box to dismiss)

Health Meta

Q&A for medical specialists, students, dietitians, and anyone with health-related questions

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

-- get all badges
select * from ( 
  SELECT Name, 
         Date, 
         userId,
         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

Options:
Switch sites:
loading Hold tight while we fetch your results