select name,count(总胜利),count(总失败),count(总胜利)+count(总失败) as 总局数
(select name,count(result) as 总胜利 from table where result=胜利 group by name
join
select name,count(result) as 总失败 from table where result=失败 group by name
on(...))
大概的这样你测试测试真实SQL
(select name,count(result) as 总胜利 from table where result=胜利 group by name
join
select name,count(result) as 总失败 from table where result=失败 group by name
on(...))
大概的这样你测试测试真实SQL
select t1.玩家,胜利局数,失败局数,(胜利局数+失败局数) as 总局数 from
(select 玩家,COUNT(结果) as 胜利局数 from PlayRst where 结果='胜利' group by 玩家)t1
join
(select 玩家,COUNT(结果) as 失败局数 from PlayRst where 结果='失败' group by 玩家)t2
on t1.玩家 = t2.玩家
sum(
case [结果] when '胜利' then
1
else
0
end) as [胜利局数],
sum(
case [结果] when '失败' then
1
else
0
end) as [失败局数],
count(1) as [总局数]
From [记录表] Group by [玩家]
FROM 成绩表
Microsoft Visual Studio
---------------------------
SQL 执行错误。已执行 SQL 语句: SELECT SUM(CASE WHEN 金额 > 0 THEN 1 ELSE 0 END) AS 成绩大于0的个数 FROM 游戏胜负表
错误源: System.Data
错误信息: IErrorInfo.GetDescription 因 E_FAIL(0x80004005) 而失败。
---------------------------
确定 帮助
---------------------------