SELECT R1.RT_RATE_INDEX , R1.FROM_CUR , R1.TO_CUR , R1.RT_TYPE , R1.EFFDT , %DateDiff(R2.EFFDT,D.CALENDAR_DATE) , D.CALENDAR_DATE ,%Round(%DecMult(R1.RATE_MULT,R1.RATE_DIV) + %DecDiv( %DecMult( (%DECMULT(R2.RATE_MULT,R2.RATE_DIV) - %DECMULT(R1.RATE_MULT,R1.RATE_DIV) ) , ( R2.TERM- %DATEDIFF(R2.EFFDT,D.CALENDAR_DATE) ) ) , (R2.TERM-R1.TERM) ) ,8) FROM PS_POS_DAYS_TBL D , PS_RT_RATE_TBL R1 , PS_RT_RATE_TBL R2 WHERE R1.TERM = ( SELECT MAX(TERM) FROM PS_RT_RATE_TBL R3 WHERE R3.RT_RATE_INDEX = R1.RT_RATE_INDEX AND R3.RT_TYPE = R1.RT_TYPE AND R3.FROM_CUR = R1.FROM_CUR AND R3.TO_CUR = R1.TO_CUR AND R3.EFFDT = R1.EFFDT AND R3.TERM < %DateDiff( R1.EFFDT, D.CALENDAR_DATE )) AND R2.RT_RATE_INDEX = R1.RT_RATE_INDEX AND R2.EFFDT = R1.EFFDT AND R2.RT_TYPE = R1.RT_TYPE AND R2.FROM_CUR = R1.FROM_CUR AND R2.TO_CUR = R1.TO_CUR AND R2.TERM = ( SELECT MIN(TERM) FROM PS_RT_RATE_TBL R4 WHERE R4.RT_RATE_INDEX = R2.RT_RATE_INDEX AND R4.RT_TYPE = R2.RT_TYPE AND R4.FROM_CUR = R2.FROM_CUR AND R4.TO_CUR = R2.TO_CUR AND R4.EFFDT = R2.EFFDT AND R4.TERM >= %DateDiff(R2.EFFDT, D.CALENDAR_DATE ))
|