I have a table with the following fields: [date], [first name], [last name], [address], [city], [state] and [zip]. I want to select only records that have data in the [first name] and [last name] fields, to eliminate duplicates based only on the [address] field and also eliminate any records that are earlier than 1/1/2000 and finally sort by zip code. I've come up with the following SQL code to select only records with data in [first name] and [last name], eliminate the duplicates based on the [address] field and sort on [zip] but the eliminate dates prior to 01/01/2000 portion fails to eliminate any records earlier than 01/01/2000. Can anyone complete the puzzle?
SELECT [DATE], [FIRST NAME], [LAST NAME], [ADDRESS],[CITY], [STATE], [ZIP] FROM MSEW2 AS C WHERE C.[REC #] NOT IN
(
SELECT A.[REC #]
FROM MSEW2 AS A, MSEW2 AS B
WHERE (A.[REC #] < B.[REC #]) AND
(A.[ADDRESS] = B.[ADDRESS]) AND
(A.[DATE] > 01/01/2000) AND
(B.[DATE] > 01/01/2000)
)
AND [CITY] IS NOT NULL AND [STATE] IS NOT NULL
ORDER BY ZIP
SELECT [DATE], [FIRST NAME], [LAST NAME], [ADDRESS],[CITY], [STATE], [ZIP] FROM MSEW2 AS C WHERE C.[REC #] NOT IN
(
SELECT A.[REC #]
FROM MSEW2 AS A, MSEW2 AS B
WHERE (A.[REC #] < B.[REC #]) AND
(A.[ADDRESS] = B.[ADDRESS]) AND
(A.[DATE] > 01/01/2000) AND
(B.[DATE] > 01/01/2000)
)
AND [CITY] IS NOT NULL AND [STATE] IS NOT NULL
ORDER BY ZIP