SELECT C.OPRID , SUM(A.POS_IMPCT_ORIG) , A.VALUE_DT , A.WRKSHEET_LINE_ITEM , A.CURRENCY_CD FROM PS_CSH_FCST_SUM A , PS_TR_CASH_POS_CFG C WHERE A.SETID = C.SETID AND A.WORKSHEET_ID = C.WORKSHEET_ID AND A.SOURCE_SET = C.SOURCE_SET AND A.GROUP_BY_FIELD = 'CUR' AND A.LINE_ITEM_TYPE='1' AND A.POS_HIST_FLAG ='N' AND A.CALC_DT IN ( SELECT MAX(B.CALC_DT) FROM PS_CSH_FCST_SUM B WHERE B.SETID = A.SETID AND B.WORKSHEET_ID = A.WORKSHEET_ID AND B.SOURCE_SET = A.SOURCE_SET AND B.GROUP_BY_FIELD = A.GROUP_BY_FIELD AND B.WRKSHEET_LINE_ITEM = A.WRKSHEET_LINE_ITEM AND B.VALUE_DT = A.VALUE_DT AND B.POSITION_CURRENCY = A.POSITION_CURRENCY AND B.GROUP_BY_FIELD = 'CUR' AND B.LINE_ITEM_TYPE='1' AND B.POS_HIST_FLAG ='N' ) GROUP BY C.OPRID, A.VALUE_DT, A.WRKSHEET_LINE_ITEM, A.CURRENCY_CD
|