在行中显示数据,而不是列

时间:2016-05-18 13:34:08

标签: sql sql-server tsql

table test1
number   color   brand   size   tiresize
-----------------------------------------
1         blue   d       5      6
3         red    b       3      3
4         red    b       3      3

table test2
number   color   brand   size   tiresize
-----------------------------------------
1         blue   d       5      6
2         blue   d       5      6
3         red    b       3      3


select count(*)
from test1

select count(*)
from test2

我检索下面的结果

3
3

我想将结果放在行中,而不是列,

有可能吗?

1 个答案:

答案 0 :(得分:1)

试试这个:

select (select count(*) from test1) as cnt1,
       (select count(*) from test2) as cnt2