这是我的问题。我有一个内部查询工作正常,但是当我将结果传递给外部查询时,我得到一个错误。我想要完成的是,在外部查询中,我想总是检查这个列(GCO_AD_KNOWLEDGE_TEST_SCORE)是否有值,如果它有一个值我想将它别名为psi得分新列名,另外如果这个列做了没有值,我想检查第二列(PSI_OVERALL_SCORE)是否有值我希望将其别名为PSI Score(新列)。任何人都想抓住这个,我会很感激。
SELECT
NVL ((CASE WHEN BB.GCO_AD_KNOWLEDGE_TEST_SCORE IS NOT NULL THEN BB.GCO_AD_KNOWLEDGE_TEST_SCORE, ) BB.PSI_OVERALL_SCORE) as PSI SCORE
else null
end
FROM(
SELECT
PARENT_PI_NUMBER,PI_CANDIDATE_NUM,REQUEST_LAST_MODIFIED_DT,Contest_number,
MAX(AA.GCO_AD_KNOWLEDGE_TEST_SCORE) KEEP (DENSE_RANK LAST ORDER BY AA.ARANK) MAX_GCO_AD_KNOWLEDGE_TEST_SCORE,
MAX(AA.PSI_OVERALL_SCORE) KEEP (DENSE_RANK LAST ORDER BY AA.ARANK) MAX_PSI_OVERALL_SCORE
FROM (
select
RANK() OVER (PARTITION BY PARENT_PI_NUMBER ORDER BY REQUEST_LAST_MODIFIED_DT) ARANK
,Contest_number,PARENT_PI_NUMBER,PI_CANDIDATE_NUM,PI_NUMBER,PSI_OVERALL_SCORE,GCO_AD_KNOWLEDGE_TEST_SCORE,REQUEST_LAST_MODIFIED_DT
from
WC_APPLICATION_EVENT_F
WHERE GCO_AD_KNOWLEDGE_TEST_SCORE != '10100'
--WHERE PI_CANDIDATE_NUM = '4639022'and GCO_AD_KNOWLEDGE_TEST_SCORE is not null
) AA
GROUP BY PARENT_PI_NUMBER,PI_CANDIDATE_NUM,REQUEST_LAST_MODIFIED_DT,Contest_number;
--ORDER By PARENT_PI_NUMBER,PI_NUMBER,REQUEST_LAST_MODIFIED_DT;
) BB;
答案 0 :(得分:0)
MX_GCO_AD_KNOWLEDGE_TEST_SCORE
是31个字符,因此除非您使用启用了长标识符的12cR2(或更高版本),否则无效。end
,并且有一个备用逗号,后面没有任何内容。GCO_AD_KNOWLEDGE_TEST_SCORE
和PSI_OVERALL_SCORE
列,但内联视图未公开这些列。听起来你想要得到:
COALESCE(BB.MX_GCO_AD_KNOWLEDGE_TEST_SCORE, BB.MX_PSI_OVERALL_SCORE) as PSI_SCORE
使用内部查询中的别名,我已将其从MAX_
修改为MX_
,以使第一个成为合法。
很难判断内部查询是否确实对数据和预期结果是正确的,但是你说它正在做你想要的。