祝大家好。 我可以执行以下代码并在oracle中获得正确的输出。但是当尝试创建视图时给出错误-列可能未加入子查询。 该视图是在SQL Server上的同一查询中创建的,但在oracle中却给出了错误。请提供帮助。
select c.Contractid
FROM FCT_EIT_CONTRACT c LEFT OUTER JOIN
DIM_EIT_PROCESS_INSTANCE psi ON psi.SURR_ID = c.PROCESS_INSTANCE_SKEY
LEFT OUTER JOIN
DIM_EIT_ACTION wa ON psi.ACTION_SKEY wa.SURR_ID
LEFT OUTER JOIN
DIM_EIT_ACTION_HISTORY ah ON wa.SURR_ID = ah.ACTION_SKEY
AND psi.SURR_ID = ah.PROCESS_INSTANCE_SKEY
AND ah.ACTION_HISTORY_ID =(SELECT MAX(ACTION_HISTORY_ID) AS Expr1
FROM DIM_EIT_ACTION_HISTORY a
WHERE (PROCESS_INSTANCE_SKEY = c.PROCESS_INSTANCE_SKEY)
AND
(psi.ACTION_SKEY = ACTION_SKEY)))
LEFT OUTER JOIN
DIM_EIT_STEP ws ON ws.SURR_ID = wa.NEXT_STEP_SKEY
WHERE (psi.CurrentStepId NOT IN (100, 130, 131, 132, 900, 902, 910))
答案 0 :(得分:0)
如果将查询中有问题的部分移至WHERE
子句,例如
SELECT c.contractid
FROM fct_eit_contract c
LEFT OUTER JOIN dim_eit_process_instance psi ON psi.surr_id = c.process_instance_skey
LEFT OUTER JOIN dim_eit_action wa ON psi.action_skey wa.surr_id
LEFT OUTER JOIN dim_eit_action_history ah ON wa.surr_id = ah.action_skey
AND psi.surr_id = ah.process_instance_skey
LEFT OUTER JOIN dim_eit_step ws ON ws.surr_id = wa.next_step_skey
WHERE psi.currentstepid NOT IN (100, 130, 131, 132, 900, 902, 910)
-- subquery moved down here
AND ah.action_history_id = (SELECT MAX(action_history_id) AS expr1
FROM dim_eit_action_history a
WHERE process_instance_skey = c.process_instance_skey
AND psi.action_skey = action_skey
);
答案 1 :(得分:0)
select
c.contractid 从FCT_EIT_CONTRACT c,DIM_EIT_PROCESS_INSTANCE psi,DIM_EIT_ACTION wa,DIM_EIT_ACTION_HISTORY啊, (通过ACTION_SKEY,PROCESS_INSTANCE_SKEY从DIM_EIT_ACTION_HISTORY组中选择MAX(ACTION_HISTORY_ID)AS ACTION_HISTORY_ID,ACTION_SKEY,PROCESS_INSTANCE_SKEY)a, DIM_EIT_STEP ws 其中psi.SURR_ID(+)= c.PROCESS_INSTANCE_SKEY 和psi.ACTION_SKEY = wa.SURR_ID(+) 和wa.SURR_ID = ah.ACTION_SKEY(+) AND psi.SURR_ID = ah.PROCESS_INSTANCE_SKEY(+) AND ah.ACTION_HISTORY_ID = a.ACTION_HISTORY_ID(+) 和(((a.ACTION_HISTORY_ID不为空,而ah.ACTION_HISTORY_ID不为空,而ah.PROCESS_INSTANCE_SKEY不为空)或 (a.ACTION_HISTORY_ID为空,而ah.ACTION_HISTORY_ID为空,而ah.PROCESS_INSTANCE_SKEY为空)) -和 -和c.PROCESS_INSTANCE_SKEY = a.PROCESS_INSTANCE_SKEY(+) -和psi.ACTION_SKEY = a.ACTION_SKEY 和ws.SURR_ID` +)= wa.NEXT_STEP_SKEY 和(psi.CurrentStepId NOT IN(100,130,131,132,900,902,910))和Contractid in(1313,27,221)