【发布时间】:2015-08-27 07:24:22
【问题描述】:
我有以下疑问:
select SUM(balvalues) from
(
select ib.CURBAL as balvalues from invbalances ib join inventory on ib.itemnum = inventory.itemnum and ib.location = inventory.location where inventory.itemnum = 'XMP-3500' and ib.siteid = 'BEDFORD'
UNION ALL
SELECT -1 * SUM(QUANTITY) from matrectrans where itemnum = 'XMP-3500' and TRANSDATE >= '16-SEP-99' and tostoreloc = 'CENTRAL'
UNION ALL
SELECT -1 * SUM(QUANTITY) from matusetrans where itemnum = 'XMP-3500' and TRANSDATE >= '16-SEP-99' and storeloc = 'CENTRAL'
);
但是我想在外部select (itemnum) 中添加另一列,这样我就可以在join 中使用另一个查询:
select SUM(balvalues), ib.itemnum
我已尝试将 itemnum 添加到每个内部选择,以确保所有 unions 和外部选择的输出列数相同,但我仍然收到此错误:
ORA-00904: "IB"."ITEMNUM": 标识符无效
如何从子查询中获取 itemnum 值?
【问题讨论】: