Hello everyone,
I've created a query that finds duplicate records. It works fine and it is shown below
qryFindDuplicates
The problem is when I execute a select query on the above query as shown below. It executes but takes about ten minutes go execute. I'm trying to figure out why. When I remove the "DISTINCT" reserved word, it executes quickly enough, but I need to use it in order to get a list of only th unique groups. I wonder if I should try indexing. Any ideas
I've created a query that finds duplicate records. It works fine and it is shown below
qryFindDuplicates
Code:
SELECT DISTINCTROW tblCurrentOptical.Group, tblCurrentOptical.Location, tblCurrentOptical.[Drawer #], tblCurrentOptical.Date, tblCurrentOptical.[Type of Payment], tblCurrentOptical.Stated, tblCurrentOptical.Verified, tblCurrentOptical.[Over/Short], tblCurrentOptical.[Deposit Number], tblCurrentOptical.[Unique Identifier]
FROM tblCurrentOptical
WHERE (((tblCurrentOptical.Location) In (SELECT [Location] FROM [tblCurrentOptical] As Tmp GROUP BY [Location],[Drawer #],[Date],[Type of Payment],[Stated],[Verified],[Over/Short],[Deposit Number],[Unique Identifier] HAVING Count(*)>1 And [Drawer #] = [tblCurrentOptical].[Drawer #] And [Date] = [tblCurrentOptical].[Date] And [Type of Payment] = [tblCurrentOptical].[Type of Payment] And [Stated] = [tblCurrentOptical].[Stated] And [Verified] = [tblCurrentOptical].[Verified] And [Over/Short] = [tblCurrentOptical].[Over/Short] And [Deposit Number] = [tblCurrentOptical].[Deposit Number] And [Unique Identifier] = [tblCurrentOptical].[Unique Identifier])))
ORDER BY tblCurrentOptical.Group, tblCurrentOptical.Location, tblCurrentOptical.[Drawer #], tblCurrentOptical.Date, tblCurrentOptical.[Type of Payment], tblCurrentOptical.Stated, tblCurrentOptical.Verified, tblCurrentOptical.[Over/Short], tblCurrentOptical.[Deposit Number], tblCurrentOptical.[Unique Identifier];
The problem is when I execute a select query on the above query as shown below. It executes but takes about ten minutes go execute. I'm trying to figure out why. When I remove the "DISTINCT" reserved word, it executes quickly enough, but I need to use it in order to get a list of only th unique groups. I wonder if I should try indexing. Any ideas
Code:
SELECT DISTINCT qryFindFullDupes.Group
FROM qryFindFullDupes;