?
Solved

Need help with special Find Duplicates Access Query

Posted on 2014-03-27
4
Medium Priority
?
309 Views
Last Modified: 2014-03-27
In a table (PRODDTA_F30026) I have two (2) fileds:
IEITM  - Short Item Number
IELITM - Long Item Number

I have discovered that, for some IELITM - Long Item Numbers there are multiple IEITM  - Short Item Numbers.

EXAMPLE:
IEITM      IELITM
15579887      8500-502                
15579924      8500-502                

I cannot have both 15579887 and 15579924 for one 8500-502.

IEITM  >>>----->   IELITM          Correct
IEITM  >>>----->   IELITM          Correct
IEITM  >>>--\  
                     >--->  IELITM          Incorrect
IEITM  >>>--/          

How do I wite an Access Query that will show only the IELITM's that have duplicate IEITM's? The table has 1.36 million lines and I need a report that shows only occurance like the example above.

SELECT PRODDTA_F30026.IEITM, PRODDTA_F30026.IELITM
FROM PRODDTA_F30026
GROUP BY PRODDTA_F30026.IEITM, PRODDTA_F30026.IELITM
ORDER BY PRODDTA_F30026.IELITM;

Any suggestions? The basic Find Duplicates Query does not work in this situation.

tw
0
Comment
Question by:Tom Winslow
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 15

Assisted Solution

by:unknown_routine
unknown_routine earned 1000 total points
ID: 39958838
Select IELITM, count(IEITM)
from  
PRODDTA_F30026
Group by IELITM
Having  count(IEITM)=2
0
 

Author Comment

by:Tom Winslow
ID: 39959017
This does not work because there are legitimate occurrences where I can have more than one occurrence of IEITM  >>>----->   IELITM where the duplicates are the same IEITM and the same IELITM.

The problem is that I have MORE THAN ONE IEITM paired to the same IELITM.

EXAMPLE - This is correct:
IEITM         IELITM
924246      APCB-10106-5            
924246      APCB-10106-5            

EXAMPLE - This is NOT correct:
IEITM            IELITM
15579887      8500-502                
15579924      8500-502                
(Note two different IEITMs)
0
 
LVL 38

Accepted Solution

by:
PatHartman earned 1000 total points
ID: 39959346
First you need a list of distinct IEITM/IELITM pairs.

Select Distinct IEITM, IELITM from your table;

Then create a find duplicates query on that query.
0
 

Author Closing Comment

by:Tom Winslow
ID: 39959633
I used both suggestions to make the query work.

SELECT DISTINCT PRODDTA_F30026.IEITM, PRODDTA_F30026.IELITM INTO [tblF30026(FindDupes-1)]
FROM PRODDTA_F30026
ORDER BY PRODDTA_F30026.IELITM;

SELECT [tblF30026(FindDupes-1)].IELITM, [tblF30026(FindDupes-1)].IEITM INTO [tblF30026(FindDupes-2)]
FROM [tblF30026(FindDupes-1)]
WHERE ((([tblF30026(FindDupes-1)].IELITM) In (SELECT [IELITM] FROM [tblF30026(FindDupes-1)] As Tmp GROUP BY [IELITM] HAVING Count(*)>1 )))
ORDER BY [tblF30026(FindDupes-1)].IELITM;

Thanks very much for your help.

tw
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question