我想得到联合,但想用不同的别名显示一列两次。例如
Select a as first from table1
union
select a as second from table1
它首先显示为输出。
但我想同时展示第一和第二。在 MSSQL 中如何实现?
我想得到联合,但想用不同的别名显示一列两次。例如
Select a as first from table1
union
select a as second from table1
它首先显示为输出。
但我想同时展示第一和第二。在 MSSQL 中如何实现?
Union 将两个查询的结果合并到一组列中。没有办法让列名更改一半。我能想到的最接近的是
select a as first
, null as second
from table1
union all
select null as first
, a as second
from table1
您将拥有所有行union all
Select a as first from table1
union all
select a as second from table1
如果我做对了:
Select a as first,a as second from table1