sql经典面试题

1.
表内容:
2005-05-09 胜
2005-05-09 胜
2005-05-09 负
2005-05-09 负
2005-05-10 胜
2005-05-10 负
2005-05-10 负
如果要生成下列结果, 该如何写sql语句?
胜 负
2005-05-09 2 2
2005-05-10 1 2

answer:

sql经典面试题

select a.rq,a.sheng,b.fu
from (select rq,count(shengfu) as sheng from shengfu  where shengfu=group by rq) a,
(select rq,count(shengfu) as fu from shengfu where shengfu= group by rq)b
where a.rq=b.rq;

 sql经典面试题

sql经典面试题

上一篇:C#中往数据库插入空值报错解决方法


下一篇:SQL给查询结果加序号