1.建表
create table temp(rq varchar(10),shengfu nchar(1))
2.插入数据
insert into temp values('2005-05-09','胜')
insert into temp values('2005-05-09','胜')
insert into temp values('2005-05-09','负')
insert into temp values('2005-05-09','负')
insert into temp values('2005-05-10','胜')
insert into temp values('2005-05-10','负')
insert into temp values('2005-05-10','负')
3.sql
select rq as '日期',sum(case when shengfu ='胜' then 1 else 0 end) as '胜' ,sum(case when shengfu='负' then 1 else 0 end) as '负' from temp group by rq
4.测试一下吧。。
日期 胜 负
2005-05-09 2 2
2005-05-10 1 2