select top 100 userid as [User Link] , bronze , silver , ...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

select top 100 userid as [User Link]
     , bronze
     , silver
     , gold
from (
select userid
, sum(case when class = 3 then 1 else 0 end) as bronze
, sum(case when class = 2 then 1 else 0 end) as silver
, sum(case when class = 1 then 1 else 0 end) as gold
from badges
group by userid
) data
--order by gold desc, silver desc , bronze desc
where gold >= bronze +silver

Enter Parameters

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