date zt 12 胜 12 胜 12 负 这个数据库里面的表 date 胜 负 12 2 1 怎么得到这个结果
select date, (select count(zt) from table where zt='胜' and date=a.date) as 胜, (select cout(zt( from table where zt='负' and date=a.date) as 负 from table a group by date
select [date], (select count(zt) from table where zt='胜' and [date]=a.[date]) as 胜, (select count(zt) from table where zt='负' and [date]=a.[date]) as 负 from table a group by [date]
select date,sum(case when zt='胜' then 1 else 0 end)'胜',sum(case when zt='负')'负' from 表名 group by date
刚刚写错了,没写完、、、 select date,sum(case when zt='胜' then 1 else 0 end)'胜',sum(case when zt='负' then 1 else 0)'负' from 表名 group by date如果有错,就把红色字的引号换换看、、好久没写都记不清楚了、、、呵呵
sum("负")这后面掉了个end、、、抱歉呵呵
晕倒、、、我糊涂了、、、、大家忽略我前面回的帖、、、 select date,sum(case when zt='胜' then 1 else 0 end)'胜',sum(case when zt='负' then 1 else 0 end)'负' from 表名 group by date如果有错,就把红色字的引号换换看、、好久没写都记不清楚了、、、
12 胜
12 胜
12 负
这个数据库里面的表
date 胜 负
12 2 1
怎么得到这个结果
(select count(zt) from table where zt='胜' and date=a.date) as 胜,
(select cout(zt( from table where zt='负' and date=a.date) as 负
from table a group by date
select [date],
(select count(zt) from table where zt='胜' and [date]=a.[date]) as 胜,
(select count(zt) from table where zt='负' and [date]=a.[date]) as 负
from table a group by [date]
select date,sum(case when zt='胜' then 1 else 0 end)'胜',sum(case when zt='负' then 1 else 0)'负' from 表名 group by date如果有错,就把红色字的引号换换看、、好久没写都记不清楚了、、、呵呵
select date,sum(case when zt='胜' then 1 else 0 end)'胜',sum(case when zt='负' then 1 else 0 end)'负' from 表名 group by date如果有错,就把红色字的引号换换看、、好久没写都记不清楚了、、、