我想在ORACLE數據庫中運行一個查詢,但我一直在失敗的白色以下錯誤「I.ID無效標識符」。 我想要做的是從嵌套查詢中選擇一個給定的結果,使用應該相互關聯嵌套查詢和上一級查詢的過濾器。SQL oracle嵌套查詢
The query is:
SELECT i.name, WOW.BI,WOW.BC, WOW.CP
from inv_investments i,
inner join (select
bi.COSTI BI,
bc.COSTI BC,
cp.COSTI AS CP
FROM
(select atom.COSTI from
(select odf.IF_CST_TOT COSTI
from prj_baselines bl
inner join odf_ca_baseline odf on odf.id = bl.id
WHERE i.id = bl.project_id
ORDER BY bl.created_date DESC) atom where rownum =1) cp,
(select odf.IF_CST_TOT COSTI
from prj_baselines bl
inner join odf_ca_baseline odf on odf.id = bl.id
where odf.if_budget = 1
AND i.id = bl.project_id) bi,
(select odf.IF_CST_TOT COSTI
from prj_baselines bl
inner join odf_ca_baseline odf on odf.id = bl.id
Where if_budget_corrente = 1
AND i.id = bl.project_id) bc ) WOW on wow.ID = i.ID
你知道如何解決嗎?每次我檢查在嵌套查詢(如WHERE i.id = bl.project_id)我得到錯誤的條款等
您是否假定每個子查詢cp,bi和bc將爲每個項目/投資ID返回一行? –