Select one record for each repeated entry (1 Viewer)

Sergeant

Someone's gotta do it
Local time
Today, 03:43
Joined
Jan 4, 2003
Messages
638
Hello All,
In my table, I have some records that are duplicated (aside from the primary key).
How can I select only one record from each set of duplicated entries? (There may be more than 2 of each of the duplicated records, but I only need to pull one of them...doesn't matter which one.)

i.e...Like a 'Find Duplicates' query, but only returning the top 1 primary key from each duplicated set.

Thanks,
Sarge.
 

Jon K

Registered User.
Local time
Today, 08:43
Joined
May 22, 2002
Messages
2,209
SELECT First(TableName.PrimaryKeyField) AS PrimaryKeyField, Field1, Field2, Field3, ...
FROM TableName
GROUP BY Field1, Field2, Field3, ...
HAVING Count(*)>1
.
 

Sergeant

Someone's gotta do it
Local time
Today, 03:43
Joined
Jan 4, 2003
Messages
638
Right on!
I have never seen the keyword "First" used.
Brilliant!
Thank You...
(You now get some reputation.)
 

Users who are viewing this thread

Top Bottom