读书人

关于COUNT 查询的

发布时间: 2012-03-08 13:30:13 作者: rapoo

关于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' 

读书人网 >SQL Server

热点推荐