0

我想从具有相同字段的 2 个表的单个联合查询中创建 2 列数据。我有 2 个表,每个表中都有“Utilizations”字段。

我尝试了以下查询,但出现错误。

select Utilizations as "Utilizations A", Utilizations as "Utilizations B" from (select Utilizations as A, 0 as B from TableA union all select 0 as A, Utilizations as B from TableB)

4

1 回答 1

1

首先,您需要为子查询设置别名,其次,您需要将外部查询中的列称为 A 和 B,而不是使用:

select  A as "Utilizations A", 
        B as "Utilizations B" 
from 
  (select  Utilizations as A, 
           0 as B 
   from TableA 
   union all 
   select 0 as A, 
          Utilizations as B 
   from TableB
  )AS t
于 2013-09-13T03:27:34.860 回答