Find Duplicates Query

M

Matt

I have a Find Duplicates Query based on the "Name Field". Some sample
results are below.

John Doe 12/3/2007
John Doe 12/15/2007
John Doe 1/28/2008

Is there a way to further restrict results to only return results that the
date fields are within 30 days of other? So in the above example, the bottom
result would not be returned because it is not within 30 days of any other
results.

Any help is greatly appreciated.

Thanks,

Matt.
 
A

Allen Browne

Use a subquery to identify whether there is another record within 30 days.

This kind of thing:

SELECT ID, [TheName], [TheDate]
FROM [Table1]
WHERE EXISTS
(SELECT Min(TheDate) AS TheOtherDate
FROM Table1 AS Dupe
WHERE Dupe.TheName = Table1.TheName
AND Dupe.ID <> Table1.ID
AND Abs(DateDiff("d", Dupe.TheDate, Table1.TheDate)) <=30);

If subqueries are new, see:
http://allenbrowne.com/subquery-01.html#AnotherRecord
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Dlookup 7
Last day of month in query 15
Help! 1
Find Duplicates Query 2
Automated transaction grouping and numbering 1
Query by DOB 1
Duplicate results. 3
dsum - 1

Top