I have table InventTrans
Columns:
itemid, datephysical, recordid
I need to find only itemid which have date datephysical older than 01-01-2016 and not exist any newer.
I'm trying this way- but its not work correctly.
select ITEMID
from INVENTTRANS itra
where itra.DATEPHYSICAL <= CONVERT(datetime, '2016-01-01')
and ITEMID not in (
select itemid
from INVENTTRANS
where itra.DATEPHYSICAL >= CONVERT(datetime, '2016-01-01')
)
group by ITEMID