View Full Version : removing duplicate records across months


hlynch
11-20-2009, 09:26 AM
I've searched the forum for the below question and have not found an answer. My apologies if I've missed it somewhere. I have limited Access knowledge and I have a database that's purpose is to count the number of cases an employee has closed.

The table I'm dealing with has three fields:
Staff_ID, Case_ID, Date_Closed

I want to produce a query that will return the Case IDs for the current month ONLY if they weren't worked in the previous month by the same Staff ID. It is possible for the same Staff member to touch the same case in multiple months but we only want to give credit to that Staff member if they haven't touched it in the past 30 days. It's also possible for multiple staff members to touch the same case. We want to give each credit, so long as they haven't touched within 30 days.

Example:
Staff_ID Case_ID Date_Closed
26001 44456748 9/22/09
26001 77888485 10/1/09
26001 44456748 10/2/09
27005 44456748 10/2/09

So if I'm pulling information for October on the above data then I would want the query to return:

Staff_ID Case_ID Date_Closed
27005 44456748 10/2/09
26001 77888485 10/1/09

The other records would be removed because the same employee touched the same case in the past 30 days.

Can someone advise how I would create the query? I would so much appreciate any help!!!

boblarson
11-20-2009, 09:36 AM
You would use a query like this:

SELECT Staff_ID, Case_ID, Date_Closed
FROM YourTableNameHere
WHERE Date_Closed > DateAdd("d", -30, Date())

hlynch
11-20-2009, 10:25 AM
Thanks so much for your reply. It's still returning all four records. It won't omit

Staff_ID Case_ID Date_Closed
26001 44456748 9/22/09
26001 44456748 10/2/09

Since this Staff touched the account in September I don't want it to return a record for either date.

Thanks!!