【发布时间】:2017-09-24 10:54:15
【问题描述】:
我正在使用 sum 聚合函数和子查询生成记录,但别名在内部查询中不起作用。 我的查询是
select UPP.item_total,
(select sum(INN.item_value_afs) total_item_value_afs from
(select distinct INN.reg_no,INN.tpt_cuo_nam,INN.item_total,INN.item_value_afs
from sigtasad.customs_import_data INN where INN.reg_no=UPP.reg_no and INN.tpt_cuo_nam=UPP.tpt_cuo_nam)) total_item_value,
sum(UPP.code_tax_amount), UPP.cmp_nam from SIGTASAD.CUSTOMS_IMPORT_DATA UPP where
UPP.reg_no='38699' and UPP.company_tin='9003247336' group by
UPP.reg_no,UPP.tpt_cuo_nam,UPP.cmp_nam,UPP.item_total ;
这个查询产生这个错误: ORA-00904: "UPP"."TPT_CUO_NAM": 标识符无效
我想要这样的结果!!!
【问题讨论】:
-
您应该编辑您的问题并提供示例数据和逻辑解释。
-
不确定您要实现的目标,但您缺少最内层子选择的别名
-
上层查询生成此错误:ORA-00904: "UPP"."TPT_CUO_NAM": invalid identifier that is my problem @ulferts
标签: sql oracle select subquery alias