select 0 idx , 'summary' name , count(*) [all] , sum(case...

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 0 idx
, 'summary' name
, count(*) [all]
, sum(case when tagbased=1 then 1 else null end) [tagbased]
, sum(case when class=1 then 1 else null end) [gold]
, sum(case when class=2 then 1 else null end) [silver]
, sum(case when class=3 then 1 else null end) [bronze]
from badges
where userid = 1675954
union
select  1
, name
, count(*) [all]
, sum(case when tagbased=1 then 1 else null end) [tagbased]
, sum(case when class=1 then 1 else null end) [gold]
, sum(case when class=2 then 1 else null end) [silver]
, sum(case when class=3 then 1 else null end) [bronze]
from badges
where userid = 1675954
group by name
order by 1

select name
, date
, class
from badges
where userid = 1675954
and name in ('announcer' COLLATE SQL_Latin1_General_CP1_CI_AS)

Enter Parameters

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