当前位置: 代码迷 >> Sql Server >> 关于COUNT 查询的
  详细解决方案

关于COUNT 查询的

热度:18   发布时间:2016-04-27 14:46:33.0
关于COUNT 查询的求助
select * from 
(select count(id) as good from table where id between '1' and '10' ) a, 
(select count(id) as good from table where id between '1' and '11') b 
结果是 一条记录里,两个字段
good good
 10 11 
请问要怎样把结果变成 两条记录,同一字段呢
good
10
11  


------解决方案--------------------
select count(id) as good from table where id between '1' and '10'
union all
select count(id) as good from table where id between '1' and '11'
------解决方案--------------------
SQL code
select count(id) as good from table where id between '1' and '10'union allselect count(id) as good from table where id between '1' and '11'
  相关解决方案