从多个表返回相关日期,包括其他表信息

从多个表返回相关日期,包括其他表信息,第1张

从多个表返回相关日期,包括其他表信息

尝试

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上的唯一标识符



欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5675128.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-17
下一篇 2022-12-16

发表评论

登录后才能评论

评论列表(0条)

保存