Keeping only one record with duplicates of a field

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a table with a field that has duplicates in a certain field. I want
to create a new table with all fields from 1st table but only one record for
those with duplicates in this certain field. It doesn't matter which record
is kept of those that are duplicates. Does anyone have the SQL code to do
this?
Thanks,
Don
 
Try the following

SELECT YourTable.FieldDupe,
First(YourTable.FieldA) as FieldA,
First(YourTable.FieldA) as FieldB,
First(YourTable.FieldA) as FieldC
FROM YourTable
GROUP BY YourTable.FieldDupe

You can use that as the source of an append query if you really need a new
table.
 
Thanks John! It works fine. I used the INTO reserved word at the end of the
SELECT to name the table I wanted this query to write to.
Don
 

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

Back
Top