SELECT
A AS '日期',
SUM(CASE WHEN B='胜' THEN 1 ELSE 0 END) AS `胜`,
SUM(CASE WHEN B='负' THEN 1 ELSE 0 END) AS `负`
FROM `table` GROUP BY A;
或 SELECT
A AS '日期',
SUM(IF(B='胜', 1, 0) AS `胜`,
SUM(IF(B='负', 1, 0) AS `负`
FROM `table` GROUP BY A;
拆成两个表,t1记录胜的场数,t2记录负的场数 select t1.date, t1.win, t2.lose from
(select A as 'date', count(B) as 'win' from T where B='win' group by A) as t1,
(select A as 'date', count(B) as 'lose' from T where B='lose' group by A) as t2
where t1.date=t2.date;
SELECT dotime,(select count(*) FROM `test1` as a where result='胜' and a.dotime=b.dotime) as 胜, (select count(*) FROM `test1` as c where result='负' and c.dotime=b.dotime) as 负 FROM `test1` as b GROUP BY dotime;