SELECT DISTINCT A.SETID , A.CUST_ID FROM PS_CUST_MSG A , PS_MESSAGE_TBL B , PS_HOLD_CD D , PS_SET_CNTRL_REC C WHERE C.RECNAME='MESSAGE_TBL' AND C.SETCNTRLVALUE = A.SETID AND B.SETID = C.SETID AND A.MESSAGE_CD = B.MESSAGE_CD AND B.MESSAGE_CD_TYPE = '01' AND B.HOLD_CD = D.HOLD_CD AND B.SETID = D.SETID AND B.EFFDT = ( SELECT MAX(BE.EFFDT) FROM PS_MESSAGE_TBL BE WHERE BE.SETID = B.SETID AND BE.MESSAGE_CD = B.MESSAGE_CD AND BE.EFFDT <= %CurrentDateIn) AND %CurrentDateIn >= A.START_DT AND %CurrentDateIn <= A.END_DT AND D.EFFDT = ( SELECT MAX(DE.EFFDT) FROM PS_HOLD_CD DE WHERE DE.SETID = D.SETID AND DE.HOLD_CD = D.HOLD_CD AND DE.EFFDT <= %CurrentDateIn)
|