select
from_currency,
to_currency,
calendar_date,
nvl(conv_rate,
nvl(last_value(conv_rate ignore nulls) over(partition by from_currency,to_currency order by calendar_date) ,
last_value(conv_rate ignore nulls) over(partition by from_currency,to_currency order by calendar_date desc)))conv_rate
from
(select
t1.from_currency,
t1.to_currency,
t1.detail_date calendar_date,
mcc1.conv_rate
from
msc_currency_conversions mcc1,
(select distinct
mcc1.from_currency,
mcc1.to_currency,
mcd.detail_date
from
msc_currency_conversions mcc1,
msc_calendar_dtl mcd
where mcd.detail_date between (select min(conv_date) from msc_currency_conversions)
and (select max(conv_date) from msc_currency_conversions)
order by 3) t1
where
t1.from_currency = mcc1.from_currency(+)
and t1.to_currency = mcc1.to_currency(+)
and t1.detail_date = mcc1.conv_date(+)
order by 3,1,2) t2