当前位置: 代码迷 >> Sql Server >> 怎么把列转行(越简单越好)
  详细解决方案

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

热度:84   发布时间:2016-04-27 15:13:57.0
如何把列转行(越简单越好)?
比如:
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)
  相关解决方案