美国东部时间晚上好,
我被困在下面的查询中,我在第12行遇到无效的标识符错误,第一个" DELETE FLAG"。不确定我是否缺少某些语法或做其他愚蠢的事情。 (我已经非常彻底地检查了我没有拼错任何东西并且所有字段都存在)
Oracle SQL Developer V. 17.2非常感谢任何帮助。
SELECT
CM.SUBJECT_PERSON_ID,
CM.COHORT_SCOPED_IDENTIFIER AS SUBJECT_STUDY_ID,
SA3.ALT_ID_VALUE AS GLOBAL_SUBJECT_ID,
V.PREFERRED_TERM AS MEMBER_STATUS,
CM.COHORT_ID,
SA2.ALT_ID_VALUE AS CRIN_ID
FROM GLENAPO.COHORT_MEMBER CM
LEFT JOIN GLENAPO.SUBJECT_ALT_ID SA1
ON SA2.SUBJECT_PERSON_ID =CM.SUBJECT_PERSON_ID
AND SA2.IDENTIFIER_TYPE_ID = 8 -- get SDG_ID
AND SA2.DELETE_FLAG = 'N'
LEFT JOIN GLENAPO.SUBJECT_ALT_ID SA1
ON SA2.SUBJECT_PERSON_ID =CM.SUBJECT_PERSON_ID
AND SA2.IDENTIFIER_TYPE_ID = 8 -- get SDG_ID
AND SA2.DELETE_FLAG = 'N'
LEFT JOIN GLENAPO.SUBJECT_ALT_ID SA2
ON SA2.SUBJECT_PERSON_ID =CM.SUBJECT_PERSON_ID
AND SA2.IDENTIFIER_TYPE_ID = 18 -- get CRIN ID
AND SA2.DELETE_FLAG = 'N'
JOIN GLENAPO.SUBJECT_ALT_ID SA3
ON SA3.SUBJECT_PERSON_ID =CM.SUBJECT_PERSON_ID
AND SA3.IDENTIFIER_TYPE_ID = 12 -- get Global Subject
AND SA3.DELETE_FLAG = 'N'
LEFT JOIN GLENAPO.VOCAB_TERM_VIEW V
ON V.TABLE_NAME = 'COHORT_MEMBER'
AND V.COLUMN_NAME = 'STATUS_CODE'
AND V.CONCEPT_ID = CM.STATUS_CODE
LEFT JOIN GLENAPO.FACILITY_REFERENCE FR ON FR.FACILITY_ID = CM.FACILITY_ID
WHERE CM.DELETE_FLAG = 'N'
答案 0 :(得分:1)
这是FROM
子句的开头:
FROM GLENAPO.COHORT_MEMBER CM LEFT JOIN
GLENAPO.SUBJECT_ALT_ID SA1
ON SA2.SUBJECT_PERSON_ID = CM.SUBJECT_PERSON_ID AND
SA2.IDENTIFIER_TYPE_ID = 8 AND -- get SDG_ID
SA2.DELETE_FLAG = 'N'
在使用表别名之前,需要先定义它。我想你打算SA1
,而不是SA2
:
FROM GLENAPO.COHORT_MEMBER CM LEFT JOIN
GLENAPO.SUBJECT_ALT_ID SA1
ON SA1.SUBJECT_PERSON_ID = CM.SUBJECT_PERSON_ID AND
SA1.IDENTIFIER_TYPE_ID = 8 AND -- get SDG_ID
SA1.DELETE_FLAG = 'N'