SELECT MAX(A.BUSINESS_UNIT) ,MAX(A.CASHIER_OFFICE) ,MAX(A.RECEIPT_NBR) ,MAX(A.TENDER_KEY) ,MAX(B.CSH_OFF_LONG_MSG) FROM PS_CSH_OFF_RCPT_T A , PS_CSH_MSG_TENDER B WHERE A.BUSINESS_UNIT = B.BUSINESS_UNIT AND A.CASHIER_OFFICE = B.CASHIER_OFFICE AND A.TENDER_KEY = B.TENDER_KEY AND B.EFF_STATUS = 'A' AND B.EFFDT = ( SELECT MAX(B2.EFFDT) FROM PS_CSH_MSG_TENDER B2 WHERE B2.BUSINESS_UNIT = B.BUSINESS_UNIT AND B2.CASHIER_OFFICE = B.CASHIER_OFFICE AND B2.TENDER_KEY = B2.TENDER_KEY AND B2.EFFDT <= %CurrentDateIn ) GROUP BY A.BUSINESS_UNIT, A.CASHIER_OFFICE, A.RECEIPT_NBR, A.TENDER_KEY
|