2 donghuangpei donghuangpei 于 2015.07.21 18:13 提问

sql查询问题,两张表的查询

表一图片说明通过表一该怎么查询成表二的样子 图片说明本人是小白啊,想了一个下午都想不到,求帮忙

3个回答

guwei4037
guwei4037   Ds   Rxr 2015.07.21 18:51
 select timeda,sum((case when result = '胜' then 1 else 0 end)) 胜,
 sum((case when result = '负' then 1 else 0 end)) 负
from Table_1 group by timeda
caozhy
caozhy   Ds   Rxr 2015.07.21 18:45
 select sum(胜), sum(负) from (SELECT timda, 胜 =
CASE result
WHEN '胜' then 1 
WHEN '败' THEN 0
END, 
负 =
CASE result
WHEN '胜' then 0
WHEN '败' THEN 1
END
from 表) group by timada
caozhy
caozhy   Ds   Rxr 2015.07.21 18:45
 select sum(胜), sum(负) from (SELECT timeda, 胜 =
CASE result
WHEN '胜' then 1 
WHEN '败' THEN 0
END, 
负 =
CASE result
WHEN '胜' then 0
WHEN '败' THEN 1
END
from 表) group by timeda
Csdn user default icon
上传中...
上传图片
插入图片