Solved

Access 2007 - duplicates

Posted on 2011-02-20
8
830 Views
Last Modified: 2012-05-11
My OS is windows 7, I have the following SQL statement which pulls out all the duplicates.  How do I modify the code to only extract the unique records.  thank u
SELECT [Seniors Club].Email, [Seniors Club].[Last Name]
FROM [Seniors Club]
WHERE ((([Seniors Club].Email) In (SELECT [Email] FROM [Seniors Club] As Tmp GROUP BY [Email] HAVING Count(*)>1 )))
ORDER BY [Seniors Club].Email;

Open in new window

0
Comment
Question by:jegajothy
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 77

Expert Comment

by:peter57r
ID: 34937560
SELECT Distinct [Seniors Club].Email, [Seniors Club].[Last Name]     .......
0
 
LVL 26

Expert Comment

by:tigin44
ID: 34937616
this wil only list the unique records...
SELECT [Seniors Club].Email, [Seniors Club].[Last Name]
FROM [Seniors Club]
WHERE [Seniors Club].Email NOT IN (SELECT [Email] 
										FROM [Seniors Club] As Tmp 
										GROUP BY [Email] 
										HAVING Count(*)>1 )
ORDER BY [Seniors Club].Email;

Open in new window

0
 

Author Comment

by:jegajothy
ID: 34937779
in response to Peter57r, I ran your code, but the results are confusing.  
There are 112 records.  a straight query for duplicates reveals 7 duplicates.  But your code reveals 110 unit records.  I have Trimed the data inthe email field to eliminate the blank or leading spaces.
Hope u can throw some light. thank u
In response to Tigin44, your code did not produce any results, which means no Unique records.
Hope u can troubleshoot the code. thank u.
0
 
LVL 77

Expert Comment

by:peter57r
ID: 34938106
What is your duplicates test based on in your duplicates query?

Your question stated you wanted unique records, and that is what Distinct will produce, based on the value of BOTH selected fields (Email + LastName) .  
0
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
LVL 39

Accepted Solution

by:
als315 earned 500 total points
ID: 34938138
If you like to select unique Email only, you can group by email and select first of Last Name:
SELECT [Seniors Club].Email, First([Seniors Club].[Last Name]) AS LastName
FROM [Seniors Club]
GROUP BY [Seniors Club].Email;
0
 
LVL 39

Expert Comment

by:als315
ID: 34938237
If you are working with db from Question 26834411, you task is not so simple.
As I can see, one person may have different emails:
bavaniraj@verizon.net      V N Rajgopalan
bavaniraj@yahoo.com      Virinchipuram Rajgopalan

And different persons can have one email:
narendra03@aol.com      Chand Arora
narendra03@aol.com      Narendra Arora


What results are you expecting to get in this cases?
0
 
LVL 39

Expert Comment

by:als315
ID: 34938286
You also may need to prepare email field for compare:
trim(Replace(Replace(Nz([Seniors Club]![Email],""),"<",""),">",""))
0
 

Author Closing Comment

by:jegajothy
ID: 34938721
your syntax produced the right and expected results. thank u
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Microsoft Office Picture Manager was included in Office 2003, 2007, and 2010, but not in Office 2013. Users had hopes that it would be in Office 2016/Office 365, but it is not. Fortunately, the same zero-cost technique that works to install it with …
Using Word 2013, I was experiencing some incredible lag when typing.  Here's what worked for me....
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

920 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now