Wrox Programmer Forums
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 4th, 2006, 09:50 AM
Registered User
 
Join Date: Jul 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

I have the same problem but I think that if you used select distinct and you had 2 duplicates it would return the first one only. The query below wouldn't return either of them. Is there a way of getting round this?


SELECT Track, COUNT(*)
FROM tbl1953
GROUP BY Track
HAVING COUNT(*) = 1;


 
Old July 5th, 2006, 12:17 PM
Friend of Wrox
 
Join Date: Dec 2005
Posts: 142
Thanks: 0
Thanked 0 Times in 0 Posts
Default

PresumingEd: I'm not sure I understand your problem.

 
Old July 11th, 2006, 12:37 PM
Authorized User
 
Join Date: Apr 2006
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

" have the same problem but I think that if you used select distinct and you had 2 duplicates it would return the first one only. The query below wouldn't return either of them. Is there a way of getting round this?


SELECT Track, COUNT(*)
FROM tbl1953
GROUP BY Track
HAVING COUNT(*) = 1;
"

If all you want is the number of unique records just do this:


SELECT Track
FROM tbl1953
GROUP BY Track



 
Old July 13th, 2006, 01:26 PM
Registered User
 
Join Date: Jul 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

If you have a table called vendor2 and you want distinct records based on a field (tin in this case) and then for the query to grab all the other fields use the following sql as a guide. The table must have a primary key (pk in this case). You can also use min on the primary key field.


SELECT vendor2.*
FROM vendor2, (SELECT tin, max(pk) as pk2 FROM vendor2 GROUP BY tin) AS pull
WHERE vendor2.pk=pull.pk2;







Similar Threads
Thread Thread Starter Forum Replies Last Post
Select Distinct kirkmc Excel VBA 3 May 5th, 2006 07:55 PM
Select Distinct? [email protected] SQL Language 5 November 5th, 2005 09:58 AM
Distinct SELECT DISTINCT question... EndEffect Classic ASP Databases 4 August 18th, 2005 08:53 AM
select distinct bmains ADO.NET 0 April 8th, 2004 02:50 PM
Select distinct elements andrin XSLT 2 August 4th, 2003 04:07 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.