PeterTaylor
Board Regular
- Joined
- Aug 5, 2010
- Messages
- 158
Dear All,
I am using Access 2013 and a novice. I have a database with ~1,000,000 that I am trying to remove the duplicates from. Using the query wizard I have created the following Query
This works well quickly identifing about 35,000 records that have duplicates. Now I want to keep the first duplicate and delete the rest. After some reading around I have come up with the following:
When I run this query it proccesses nearly to the end of the progress bar then appears to hang ( I have left it for ~1 hour). Is there something wrong with the syntax? I would appreciate some guidance.
Regards,
Peter
I am using Access 2013 and a novice. I have a database with ~1,000,000 that I am trying to remove the duplicates from. Using the query wizard I have created the following Query
Code:
SELECT All_Soils.LAT, All_Soils.LONG, All_Soils.Au_ppb, All_Soils.Ag_ppm, All_Soils.As_ppm, All_Soils.Cu_ppm, All_Soils.Ni_ppm, All_Soils.Co_ppm, All_Soils.Pb_ppm, All_Soils.Zn_ppm, All_Soils.ID
FROM All_Soils
WHERE (((All_Soils.LAT) In (SELECT [LAT] FROM [All_Soils] As Tmp GROUP BY [LAT],[LONG],[Au_ppb],[Ag_ppm],[As_ppm],[Cu_ppm],[Ni_ppm],[Co_ppm],[Pb_ppm],[Zn_ppm] HAVING Count(*)>1 And [LONG] = [All_Soils].[LONG] And [Au_ppb] = [All_Soils].[Au_ppb] And [Ag_ppm] = [All_Soils].[Ag_ppm] And [As_ppm] = [All_Soils].[As_ppm] And [Cu_ppm] = [All_Soils].[Cu_ppm] And [Ni_ppm] = [All_Soils].[Ni_ppm] And [Co_ppm] = [All_Soils].[Co_ppm] And [Pb_ppm] = [All_Soils].[Pb_ppm] And [Zn_ppm] = [All_Soils].[Zn_ppm])))
ORDER BY All_Soils.LAT, All_Soils.LONG, All_Soils.Au_ppb, All_Soils.Ag_ppm, All_Soils.As_ppm, All_Soils.Cu_ppm, All_Soils.Ni_ppm, All_Soils.Co_ppm, All_Soils.Pb_ppm, All_Soils.Zn_ppm;
Code:
SELECT All_Soils.LAT, All_Soils.LONG, All_Soils.Au_ppb, All_Soils.Ag_ppm, All_Soils.As_ppm, All_Soils.Cu_ppm, All_Soils.Ni_ppm, All_Soils.Co_ppm, All_Soils.Pb_ppm, All_Soils.Zn_ppm, Max(All_Soils.ID) AS MaxOfID
FROM All_Soils
GROUP BY All_Soils.LAT, All_Soils.LONG, All_Soils.Au_ppb, All_Soils.Ag_ppm, All_Soils.As_ppm, All_Soils.Cu_ppm, All_Soils.Ni_ppm, All_Soils.Co_ppm, All_Soils.Pb_ppm, All_Soils.Zn_ppm
HAVING (((All_Soils.LAT) In (SELECT [LAT] FROM [All_Soils] As Tmp GROUP BY [LAT],[LONG],[Au_ppb],[Ag_ppm],[As_ppm],[Cu_ppm],[Ni_ppm],[Co_ppm],[Pb_ppm],[Zn_ppm] HAVING Count(*)>1 And [LONG] = [All_Soils].[LONG] And [Au_ppb] = [All_Soils].[Au_ppb] And [Ag_ppm] = [All_Soils].[Ag_ppm] And [As_ppm] = [All_Soils].[As_ppm] And [Cu_ppm] = [All_Soils].[Cu_ppm] And [Ni_ppm] = [All_Soils].[Ni_ppm] And [Co_ppm] = [All_Soils].[Co_ppm] And [Pb_ppm] = [All_Soils].[Pb_ppm] And [Zn_ppm] = [All_Soils].[Zn_ppm])))
ORDER BY All_Soils.LAT, All_Soils.LONG, All_Soils.Au_ppb, All_Soils.Ag_ppm, All_Soils.As_ppm, All_Soils.Cu_ppm, All_Soils.Ni_ppm, All_Soils.Co_ppm, All_Soils.Pb_ppm, All_Soils.Zn_ppm;
Regards,
Peter