Sample Header Ad - 728x90

perform multiple conditional join on multiple tables

0 votes
1 answer
1794 views
I have a situation where I need to get result based on conditional joins For example, SELECT CGI.SALES_BRAND_BSNSS_ID, CGI.SALES_BRAND_CD, NVL(MTRX. matrix_score_cd,'RV1') MATRIX_SCORE_CD, MDL.CORP_GROUP_ID, MDL.MKTBRIDGE_RUN MKTBRIDGE_RUN_CD, MDL.MKTBRIDGE_GROW MKTBRIDGE_GROW_CD, MDL.MACRO_SEG MACRO_SEG_CD FROM BIRTAB.CGI_ACTIVE_CUST_SEG_V MDL INNER JOIN BIRTAB.SBBID_CGI_HIST_XREF CGI ON MDL.CORP_GROUP_ID = CGI.CORP_GROUP_ID LEFT JOIN BIRTAB.CUST_SEG_SCORE_MATRIX MTRX ON -- if below two join conditions matches then it need to go to 3rd join condition else ignore all joins, NVL(trim(MDL.ECHECK_DECILE_CD),'%') = trim(MTRX. ECHECK_DECILE_CD) AND NVL(trim(MDL.MACRO_SEG),'%') = trim(MTRX.MACRO_SEGMENT_CD) AND -- if the above two joins matches and below join doesn't matches then ignore below two joins and get result based on above 2 joins NVL(trim(MDL.MKTBRIDGE_RUN),'%') = trim(MTRX.MKT_BRIDGE_RUN_CD) AND -- if the above three joins matches and below join doesn't matches then ignore below join and get result based on above 3 joins NVL(trim(MDL.MKTBRIDGE_GROW),'%') = trim(MTRX.MKT_BRIDGE_GROW_CD) Can anyone suggest some ideas to perform this logic. Ty
Asked by heye (129 rep)
Jan 25, 2019, 02:04 AM
Last activity: Jan 6, 2022, 07:01 AM