Hello, Experts!
I am still a newbie in SQL Server and I need your help. I have a table with the following structure:
Container_no, nvarchar(12)
Line, nchar(10)
Activity_Date, datetime
Activity, nvarchar(50)
Each container could have 50 or more activity records with different dates. I need to be able to retrieve the container numbers that do not have activity between the dates 01/01/2011 and 12/31/2011. I tried the following script but doesn't work:
SELECT DISTINCT Container_no
FROM Reefer_Movements
WHERE NOT EXISTS (SELECT Container_no, Activity_Date
FROM Reefer_Movements
WHERE Activity_Date BETWEEN '01/01/2011' AND '12/31/2011')
ORDER BY Container_no
Any help would be very much appreciated.
Thanks!
SELECT DISTINCT Container_no
FROM Reefer_Movements
WHERE Activity Date < '01/01/2011' AND Activity Date > '12/31/2011'
ORDER BY Container_no