insert into tb1 values('2005-05-09','胜')
insert into tb1 values('2005-05-09','胜')
insert into tb1 values('2005-05-09','负')
insert into tb1 values('2005-05-09','负')
insert into tb1 values('2005-05-10','负')
insert into tb1 values('2005-05-10','负')
insert into tb1 values('2005-05-10','胜')
select rq,jg,count(jg) as cs into #t
from tb1
group by rq,jg
order by rq
select rq,sum(case jg when '胜' then cs else 0 end) as '胜',sum(case jg when '负' then cs else 0 end ) as '负'
from #t
group by rq
drop table #t
rq 胜 负
------------------------------------------------------ ----------- -----------
2005-05-09 00:00:00.000 2 2
2005-05-10 00:00:00.000 1 2