Help with Query

T

TotallyConfused

I would appreciate any help with creating a query that would identify
duplicate
rows per address field. I ran a duplicate query made a new table with all
duplicates. Now I need to create a query that will flag the duplicates in
the following manner. I want to query to go through these duplicate rows and
keep only flag the row that has duplicate address, city, state and zip. Looks
at the age to keep the row with the older age. If age is the same for both
rows than look at the
gender field, if gender field is the same than choose only the first row.
Does this make sense? Thank you for any help you can provide.
 
J

John Spencer

Well, if age is the same and gender is different then do you want to
keep both rows?

And do you want to flag the row by setting a value in some field or just
delete the other duplicate rows or just display one of the duplicate
records in a select query.

By the way, first row makes little sense unless you specify the order of
the rows by some means.

This returns one row per duplicate set. It may not be what you want
SELECT Address, City, State, ZIP
, Max(Age) as TheAge
, Max(Gender) as TheGender
FROM DuplicateList
GROUP BY Address, City, State, Zip

'====================================================
John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
'====================================================
 
T

TotallyConfused

Thank you Mr. Spencer for responding. Very much appreciated. I am sorry I
wasn't more specific. I do want to flag the dup records in field titled
("Main Rec" with "Yes") and yes I do want it sorted by address. The final
out come is that regardless of gender or age we only want to keep one address
and in cases where the address is the same, gender and age are the same we
only want to keep the first row. Thank you again.
 

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

Top