Hi all, I need to calculate a lag variable @b and then update this into my RatesTable. Any ideas, I was sure this would work but the value IncenRate updates to null. it is like @b variable does not have a value but it reports the correct value in the select return. Any help is appreciated
Glenn
select
@b:=(RT1.mtg30 * .25) + (RT2.mtg30 * .5) + (RT3.mtg30 * .25)
from
RatesTable RT
left join
RatesTable RT1
on
date_add(RT1.period, interval 1 month) = RT.Period
left join
RatesTable RT2
on
date_add(RT2.period, interval 2 month) = RT.Period
left join
RatesTable RT3
on
date_add(RT3.period, interval 3 month) = RT.Period;
update RatesTable set IncenRate = @b;
Glenn
select
@b:=(RT1.mtg30 * .25) + (RT2.mtg30 * .5) + (RT3.mtg30 * .25)
from
RatesTable RT
left join
RatesTable RT1
on
date_add(RT1.period, interval 1 month) = RT.Period
left join
RatesTable RT2
on
date_add(RT2.period, interval 2 month) = RT.Period
left join
RatesTable RT3
on
date_add(RT3.period, interval 3 month) = RT.Period;
update RatesTable set IncenRate = @b;