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:
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;
时间: 2024-10-25 05:32:18