当前位置: 代码迷 >> Sql Server >> 怎么用1个select 语句选出group by 后符合要求的结果
  详细解决方案

怎么用1个select 语句选出group by 后符合要求的结果

热度:46   发布时间:2016-04-27 21:21:11.0
如何用1个select 语句选出group by 后符合要求的结果
select   count(*)   as   Count,Type   from   table1   group   by   type   后得到结果  

count               ,   Type
1                             A
10                           B
2                             C

现在我想要只列出   type=A   或   type=C   的,这个select   语句怎么写?

------解决方案--------------------
select count(*) as Count,Type from table1 group by type having type= 'A ' or type= 'C '
------解决方案--------------------
select count(*) as Count,Type
from table1
where type = 'A ' or type = 'C '
group by type
------解决方案--------------------
select count(*) as Count,Type from table1 Where Type = 'A ' Or type = 'C ' group by type
  相关解决方案