读书人

怎么把列转行(越简单越好)

发布时间: 2012-03-07 09:13:51 作者: rapoo

如何把列转行(越简单越好)?
比如:
select max(time) from ....where ...
union
select min(time) from ....where ...

得到
2007-9-1
2007-9-2

希望得到:
2007-9-1 2007-9-2

[解决办法]
--如果where条件不同,甚至from都不同:

select
(select max(time) from ....where ...),
(select min(time) from ....where ...)

--例如

select
(select max(id) from sysobjects where xtype = 'x '),
(select min(id) from syscolumns where xtype = 175)

读书人网 >SQL Server

热点推荐