declare @dt date = dateadd(m,-6,getdate())
--update rm00101 set inactive = 1
select c.custnmbr, c2.custnmbr
from rm00101 c
left join (
select distinct custnmbr from rm20101 where docdate > @dt
union select distinct custnmbr from rm30101 where docdate > @dt
) c2 on c2.custnmbr = c.custnmbr
where c2.CUSTNMBR is null
and inactive = 0