尝试:
SELECt *FROM (SELECt OAS.ASM_SUBJECT_ID as "P Number", OAS.ASM_ID as "Assessment ID", OAS.ASM_START_DATE as "Assessment Start", OAS.ASM_END_DATE as "Assessment End", ORE.TEAM, ORE.WORKER, OSE.SEV_ID as "Event ID", OSE.SEV_ACTUAL_DATE as "Event Start", OSE.SEV_OUTCOME_DATE as "Event End", ROUND(OAS.ASM_START_DATE -OSE.SEV_ACTUAL_DATE,0) as "Likely", row_number() over(PARTITION BY OAS.ASM_ID ORDER BY abs(OAS.ASM_START_DATE - OSE.SEV_ACTUAL_DATE))as "Row Number" FROM O_ASSESSMENTS OAS LEFT JOIN O_RESPonSIBILITIES ORE ON OAS.ASM_ID = ORE.RES_REC_ID LEFT JOIN O_SERVICE_EVENTS OSE ON OAS.ASM_SUBJECT_ID = OSE.SEV_SUBJECT_ID ANDOSE.SEV_CODE IN ('ICS_E3','CPINVEST') AND ROUND(OAS.ASM_START_DATE - OSE.SEV_ACTUAL_DATE,0) = 0 Where OAS.ASM_QSA_ID IN ('AA1329','AA521') )WHERe "Row Number" = 1
请注意,这假定
RES_REC_ID是
O_RESPONSIBILITIES上的唯一标识符。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)