-- look at all employees that are 50 - 55
select e.employid, e.BRTHDATE,ded.DEDUCTON,
ds.dedyrmax as SetupDeductionYearMax,
ded.dedyrmax as EmpDeductionYearMax
from upr00100 e
join upr00500 ded on ded.EMPLOYID = e.EMPLOYID and ded.DEDUCTON = '401k'
join UPR40900 ds on ds.DEDUCTON = ded.DEDUCTON
where
--employees between 50 and 55
e.BRTHDATE between dateadd(month, -((55 * 12)), getdate()) and dateadd(month, -((50 * 12)), getdate())
order by brthdate
--update the max deduction for this employee set
update upr00500 set DEDYRMAX = ds.DEDYRMAX + 6000
from upr00100 e
join upr00500 ded on ded.EMPLOYID = e.EMPLOYID and ded.DEDUCTON = '401k'
join UPR40900 ds on ds.DEDUCTON = ded.DEDUCTON
where
--employees between 50 and 55
e.BRTHDATE between dateadd(month, -((55 * 12)), getdate()) and dateadd(month, -((50 * 12)), getdate())