Tuesday, May 24, 2011

CINTINIOUS RATE PRINT

-- when fx rate change then value will insert the fx_rate table.
-- But we need to show the continious rate for each date from the fx_rate table.

--example
-- let the rate table is as follows :

-- date val
-- 1/1/2011 5
-- 1/10/2011 15
-- 1/15/2011 10
-- 1/20/2011 25

-- Now output will be continius rate of 1/1/2011 to 1/20/2011
-- for this the rate from 1/1/2011 to 1/9/2011 will be 5 as the rate change at 1/10/2011
-- and similarly the rate of 1/10/2011 to 1/20/2011 will be 15


create table fx_rate
(
dt date,
val integer
)
commit;

select a.*,(select val from fx_rate where dt=(select max(dt) from fx_rate where dt<=a.value_date)) value from
(
select ((select min(dt) from fx_rate) + level - 1) value_date from dual connect by
level<=((select max(dt) from fx_rate) - (select min(dt) from fx_rate) + 1)
) a

No comments:

Post a Comment