SELECT A.TXN_KEY , A.ASSET_SEQ_NBR , MAX(B.DISTRIBUTION_ID) , SUM( CASE WHEN (B.DISTRIBUTION_ID IS NULL OR A.DISTRIBUTION_ID = B.DISTRIBUTION_ID ) THEN 0 ELSE %Sql(RE_DISTRIB_AMT_CALC, A.DECIMAL_POSITIONS, %SQL(RE_RNDFLG_AMT_SEL, A.ROUNDING_APPLIED, A.AMOUNT_3, C.AMOUNT, A.AMOUNT), A.PERCENTAGE) END) , SUM( CASE WHEN (B.DISTRIBUTION_ID IS NULL OR A.DISTRIBUTION_ID = B.DISTRIBUTION_ID ) THEN 0 ELSE %Sql(RE_DISTRIB_AMT_CALC, A.DECIMAL_POSITIONS, %SQL(RE_RNDFLG_AMT_SEL, A.ROUNDING_APPLIED, A.AMOUNT_1, C.OBLIGATION_REDUCE, A.OBLIGATION_REDUCE), A.PERCENTAGE) END) , SUM( CASE WHEN (B.DISTRIBUTION_ID IS NULL OR A.DISTRIBUTION_ID = B.DISTRIBUTION_ID ) THEN 0 ELSE %Sql(RE_DISTRIB_AMT_CALC, A.DECIMAL_POSITIONS, %SQL(RE_RNDFLG_AMT_SEL, A.ROUNDING_APPLIED, A.AMOUNT_2, C.INTEREST_AMOUNT, A.INTEREST_AMOUNT), A.PERCENTAGE) END) FROM PS_RE_LS_AM_PSS_VW C RIGHT OUTER JOIN PS_RE_LS_AM_PSH_VW A ON (C.TXN_KEY = A.TXN_KEY) LEFT OUTER JOIN PS_RE_LS_DS_RND_VW B ON (A.LS_KEY = B.LS_KEY AND A.AMND_NBR = B.AMND_NBR AND A.ASSET_SEQ_NBR = B.ASSET_SEQ_NBR) GROUP BY A.TXN_KEY , A.ASSET_SEQ_NBR
|