April 9, 2024
Contribute to the Microsoft 365 and Office forum!
Click here to learn more 💡
May 10, 2024
Access Forum Top Contributors:
Remove duplicates in a query
The first columns have machine names and the second column is the user who owns that machines
I would like to run a query that deletes all the dups...keeping only one of them.
So if you have four machine names and four of the same user names. I want it to find all the machine names and delete all except for one.
How do I do that?
I did a query wizard "find match" but it wont keep one of each.
Report abuse
Thank you.
Reported content has been submitted
Best wishes, HansV
https://www.eileenslounge.com
Report abuse
Thank you.
Reported content has been submitted
Was this reply helpful?
Sorry this didn't help.
Great! Thanks for your feedback.
How satisfied are you with this reply?
Thanks for your feedback, it helps us improve the site.
How satisfied are you with this reply?
Thanks for your feedback.
Thanks for your reply!
Report abuse
Thank you.
Reported content has been submitted
Was this reply helpful?
Sorry this didn't help.
Great! Thanks for your feedback.
How satisfied are you with this reply?
Thanks for your feedback, it helps us improve the site.
How satisfied are you with this reply?
Thanks for your feedback.
Try a query like this, where
Table1 = table name
ID = primary key
MachineName, Owner = fields on which you're looking for duplicates.
DELETE Table1.ID
FROM Table1
WHERE Table1.ID Not In (SELECT Min(ID) FROM Table1 GROUP BY MachineName, Owner)
Best wishes, HansV
https://www.eileenslounge.com
Report abuse
Thank you.
Reported content has been submitted
Was this reply helpful?
Sorry this didn't help.
Great! Thanks for your feedback.
How satisfied are you with this reply?
Thanks for your feedback, it helps us improve the site.
How satisfied are you with this reply?
Thanks for your feedback.
I need something that will strip all dups leaving only one of each machine name and user.
Am I doing something wrong?
Thank you
Report abuse
Thank you.
Reported content has been submitted
Was this reply helpful?
Sorry this didn't help.
Great! Thanks for your feedback.
How satisfied are you with this reply?
Thanks for your feedback, it helps us improve the site.
How satisfied are you with this reply?
Thanks for your feedback.
You must of course use the exact names of your table and the fields in it, you can't just try to run the query as I posted it. If you have names with spaces or punctuation, enclose the name in square brackets [ ], e.g.
DELETE [My Table].[Key Field]
FROM [My Table]
WHERE [My Table].[Key Field] Not In (SELECT Min([Key Field]) FROM [My Table] GROUP BY [Machine Name], [Machine Owner])
Best wishes, HansV
https://www.eileenslounge.com
Report abuse
Thank you.
Reported content has been submitted
Was this reply helpful?
Sorry this didn't help.
Great! Thanks for your feedback.
How satisfied are you with this reply?
Thanks for your feedback, it helps us improve the site.
How satisfied are you with this reply?
Thanks for your feedback.
let me try something else.
Thank you
Report abuse
Thank you.
Reported content has been submitted
Was this reply helpful?
Sorry this didn't help.
Great! Thanks for your feedback.
How satisfied are you with this reply?
Thanks for your feedback, it helps us improve the site.
How satisfied are you with this reply?
Thanks for your feedback.
Best wishes, HansV
https://www.eileenslounge.com
Report abuse
Thank you.
Reported content has been submitted
Was this reply helpful?
Sorry this didn't help.
Great! Thanks for your feedback.
How satisfied are you with this reply?
Thanks for your feedback, it helps us improve the site.
How satisfied are you with this reply?
Thanks for your feedback.
Report abuse
Thank you.
Reported content has been submitted
Was this reply helpful?
Sorry this didn't help.
Great! Thanks for your feedback.
How satisfied are you with this reply?
Thanks for your feedback, it helps us improve the site.
How satisfied are you with this reply?
Thanks for your feedback.
Question Info
Last updated October 5, 2021 Views 220 Applies to: