Avatar of dzirkelb
dzirkelbFlag for United States of America

asked on 

How to produce count of distinct records

I am trying to get a count of distinct part numbers from a table where a part could be listed more than one time.  Here is an example table of data:

Master123 | Detail123
Master123 | Detail123
Master123 | Detail456
Master123 | Detail456
Master123 | Detail456
Master123 | Detail789
Master456 | Detail789

I want the count of different "Detail" numbers.  In this case, I want the query to produce 3 as a result for Master123, and 1 for Master456.
Microsoft AccessSQL

Avatar of undefined
Last Comment
Sujith
SOLUTION
Avatar of Sujith
Sujith
Flag of United Kingdom of Great Britain and Northern Ireland image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
SOLUTION
Avatar of Sujith
Sujith
Flag of United Kingdom of Great Britain and Northern Ireland image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of dzirkelb
dzirkelb
Flag of United States of America image

ASKER

Thanks for the fast responses!  I'm using Access 2000, so maybe I have some incorrect syntax as I'm getting an error.  This is the exact query:

SELECT  bomref.fcparent, Count(DISTINCT bomref.fcomponent) AS CountOffcomponent
FROM bomref
GROUP BY bomref.fcparent
HAVING (((bomref.fcparent)="PGMUVCBKRC"));

here is the error:

Syntax error (missing operator) in quyery expression 'Count(DISTINCT bomref.fcomponent)'.
ASKER CERTIFIED SOLUTION
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
SOLUTION
Avatar of Sujith
Sujith
Flag of United Kingdom of Great Britain and Northern Ireland image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Microsoft Access
Microsoft Access

Microsoft Access is a rapid application development (RAD) relational database tool. Access can be used for both desktop and web-based applications, and uses VBA (Visual Basic for Applications) as its coding language.

226K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo