表 msg
id type
1 1
2 2
3 2
4 1
5 2
6 1
. .
. .
. .type 只有两种类型 1或者2
求用 一条语句 查询出 type =1 和type =2 的个数是一条 谢谢
id type
1 1
2 2
3 2
4 1
5 2
6 1
. .
. .
. .type 只有两种类型 1或者2
求用 一条语句 查询出 type =1 和type =2 的个数是一条 谢谢
调试欢乐多
TYPE,
COUNT(*) as 个数
from msg
group by [type]
[type],
COUNT(*) as 个数
from msg
group by [type]
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的个数]
from
msg