我正在尝试将表链接到选择查询,我得到错误:ORA-00905:缺少关键字。这是我写过的oracle sql。
当我单独运行数据时,数据拉动。当我尝试加入它时,我得到了错误。我尝试按照我在互联网上找到的一些帮助信息添加Group BY和Order,但仍然会收到同样的错误。
SELECT
AS_MASTER_NF.CONTRACT_NO
, AS_HISTORY_NF.AH_CONTRACT_NBR
, AS_MASTER_NF.ID
, AS_MASTER_NF.A_INVENT_DATE
, AS_MASTER_NF.A_DISP_DATE
FROM INFL_IDS.AS_MASTER_NF
LEFT JOIN (SELECT
NVL(SUBSTR(ALTERNATE_ID, 0, INSTR(ALTERNATE_ID, '*')-1), ALTERNATE_ID) AS ASSET
, AS_HISTORY_NF.AH_CONTRACT_NBR
FROM INFL_IDS.AS_HISTORY_NF
WHERE LENGTH (AH_CONTRACT_NBR)> 3) AS ASHISTORY
ON INFL_IDS.AS_MASTER_NF.ID = INFL_IDS.ASHISTORY.ASSET
WHERE AS_MASTER_NF.A_INVENT_DATE IS NOT NULL
GROUP BY
AS_MASTER_NF.CONTRACT_NO
, AS_HISTORY_NF.AH_CONTRACT_NBR
, AS_MASTER_NF.ID
, AS_MASTER_NF.A_INVENT_DATE
, AS_MASTER_NF.A_DISP_DATE
ORDER BY
AS_MASTER_NF.CONTRACT_NO
, AS_HISTORY_NF.AH_CONTRACT_NBR
, AS_MASTER_NF.ID
, AS_MASTER_NF.A_INVENT_DATE
, AS_MASTER_NF.A_DISP_DATE
FETCH FIRST 20 ROWS ONLY
答案 0 :(得分:1)
变化:
ON INFL_IDS.AS_MASTER_NF.ID = INFL_IDS.ASHISTORY.ASSET
为:
ON INFL_IDS.AS_MASTER_NF.ID = ASHISTORY.ASSET
因为ASHISTORY
不是INFL_IDS
架构下的表或视图,而只是在此sql中定义的子查询。