我使用sum集合函數和子查詢生成記錄,但別名在內部查詢中不起作用。 我的查詢是表別名在oracle的子查詢中不起作用
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」:無效的標識符
我想是這樣的結果!
您應該編輯您的問題並提供樣本數據和邏輯解釋。 –
不知道你想達到什麼,但你缺少最內層子查詢的別名 – ulferts
上面的查詢生成此錯誤:ORA-00904:「UPP」。「TPT_CUO_NAM」:無效標識符 這是我的問題 @ulferts –