select ID,DAY,Val,
nullif(Last_Value(Val) over(partition by ID order by DAY
Rows between Unbounded Preceding and Unbounded Following),Val) as LastVal
from (select 'XXX' as ID,to_date('2005/10/3','fmyyyy/mm/dd') as DAY,100 as Val from dual
union select 'XXX',to_date('2005/11/10','fmyyyy/mm/dd'),200 from dual
union select 'XXX',to_date('2006/12/1' ,'fmyyyy/mm/dd'),300 from dual
union select 'YYY',to_date('2006/12/4' ,'fmyyyy/mm/dd'),400 from dual
union select 'YYY',to_date('2006/12/3' ,'fmyyyy/mm/dd'),500 from dual
union select 'ZZZ',to_date('2006/2/10' ,'fmyyyy/mm/dd'),600 from dual
union select 'ZZZ',to_date('2006/6/16' ,'fmyyyy/mm/dd'),700 from dual
union select 'ZZZ',to_date('2006/9/03' ,'fmyyyy/mm/dd'),800 from dual);