This query returns all the testing dates for item no's where the testing date is older than 180 days. But I only want to return the record if it's been more than 180 days for the most recent testing date. Your help is greatly appreciated. Thank you.
select a.assignno, a.itemno, a.serno ,a.oan, a.description, a.brand, a.modelno,c.tested--,datediff(day,getdate(), c.tested)
from pp_invt a
inner join training.dbo.armshist c on a.serno = c.SERNO
where a.CATEGORYNO = 'ECSO09PRC00000049'
and a.ASSIGNNO = 'ECSO09PER000147'
and datediff(day,getdate(), c.tested) < -180