name, type, version
示例数据
a, 1, 一号
b, 1, 一号
a, 1, 二号
b, 2, 一号
a, 2, 一号
b, 2, 二号
a, 2, 二号
b, 2, 三号
要求结果
type为1的数量,type为2的数量, version
2 2 一号
1 2 二号
0 1 三号
select sum(case when type=1 then 1 else 0 end) as [type为1的数量],
sum(case when type=2 then 1 else 0 end) as [type为2的数量],
version
from tablename
group by version
3554



被折叠的 条评论
为什么被折叠?



