我有两个要合并为一个的查询。
第一个查询是
select
a.desc as desc
,sum(bdd.amount) as amount
from
t_main c
left outer join
t_direct bds on (bds.mainId = c.id)
left outer join
tm_defination a on (a.id = bds.defId)
where
c.descId = 1000000134
group by
a.desc;
它返回以下结果
desc amount
NW 12.00
SW 10
我有第二个查询
select
a.desc as desc
,sum(bdd.newAmt) as amount1
from
t_main c
left outer join
t_newBox b on (b.mainId = c.id)
left outer join
t_transition c on (c.id = b.tranId)
left outer join
tm_defination def a on (a.id = c.defId)
where
c.descId = 1000000134
group by
a.desc;
此查询返回以下结果:
desc amount
NW 4.00
我想将这两个查询结合起来,这样我就可以像这样出去了..
desc amount amount1
NW l2.00 4.00
SW 10.00
我UNION
在查询 1 和查询 2 之间进行了尝试,但结果显示为
desc amountamount1
NW 16.00
SW 10.00
这不是我想要的。
请让我知道如何创建查询或表达式来实现此目的。
谢谢