SELECT DISTINCT A.SETID , A.PPRC_PROMO_CD , B.DST_ID , D.LANGUAGE_CD , D.DESCR , D.DESCRSHORT FROM PS_PPRC_PROMO_TBL A , PS_DST_CODE_TBL B , PS_SET_CNTRL_REC CC , PS_DST_CODE_LG D WHERE A.SETID = CC.SETCNTRLVALUE AND CC.RECNAME = 'DST_CODE_TBL' AND B.SETID = D.SETID AND B.DST_ID = D.DST_ID AND B.EFFDT = D.EFFDT AND CC.SETID = B.SETID AND B.DST_USE = 'DIS' AND B.EFFDT = ( SELECT MAX(B_ED.EFFDT) FROM PS_DST_CODE_TBL B_ED WHERE B.SETID = B_ED.SETID AND B.DST_ID = B_ED.DST_ID AND B_ED.EFFDT <= %CurrentDateIn) AND (EXISTS( SELECT 'X' FROM PS_PPRC_PROMO_TBL C WHERE A.SETID = C.SETID AND A.PPRC_PROMO_CD = C.PPRC_PROMO_CD AND B.DST_ID = C.DST_ID) OR EXISTS( SELECT 'X' FROM PS_TD_PRO_MERC_CUS D WHERE A.SETID = D.SETID AND A.PPRC_PROMO_CD = D.PPRC_PROMO_CD AND B.DST_ID = D.DST_ID))
|