If you have gaps in your table, you can use this:declare @year_from int=2013;declare @month_from int=3;declare @year_to int=2014;declare @month_to int=5;with cte (y,m) as (select @year_from ,@month_from union all select y+case when m>=12 then 1 else 0 end ,case when m>=12 then 1 else m+1 end from cte where y*100+m<@year_to*100+@month_to )select a.[month] ,a.[year] ,a.rate from (select a.m as [month] ,a.y as [year] ,b.rate ,row_number() over (partition by a.y,a.m order by b.[year] desc,b.[month] desc) as rn from cte as a left outer join yourtable as b on b.[year]*100+b.[month]<=a.y*100+a.m ) as a where a.rn=1 order by a.[year] ,a.[month]
Also, in order for the rate being 105 on month 3 and 4 in 2014, record 3 in your table probably would be 2013 (not 2014).