Avatar of flemingg62
flemingg62 asked on

Count number of Unique occurance of ONE field in and Access query

I have a Access Query that returns a lot of data (25,360 in current set) I  want to count how may Unique Building and Floors there are (In this Case 1 building and 2 floors) and I can't figure out how to do in within 1 query (I prefer not to create lots of  a sub query to count the Building, Floor etc... separately)

Attached is sample output I'm trying to achieve and a the query design

Design.PNGRestlts.PNG
-----------
SELECT [Lookup Current Surveys].[Adept Survey UID], [Lookup Current Surveys].[Accordant SUS UID], [Lookup Current Surveys].Instance, [Lookup Curent Project].Sector, Count([SUS Source - Survey Data - Srva].ID) AS Observations, Count([SUS Source - Survey Data - Locn].Building) AS [Building Count], Count([SUS Source - Survey Data - Locn].Floor) AS [Floor Count]
FROM [SUS Source - Survey Data - Locn] INNER JOIN (([Lookup Current Surveys] INNER JOIN [Lookup Curent Project] ON [Lookup Current Surveys].[Adept Survey UID] = [Lookup Curent Project].[Adept Survey UID]) INNER JOIN [SUS Source - Survey Data - Srva] ON [Lookup Current Surveys].[Accordant SUS UID] = [SUS Source - Survey Data - Srva].Survey) ON [SUS Source - Survey Data - Locn].Code = [SUS Source - Survey Data - Srva].Location
GROUP BY [Lookup Current Surveys].[Adept Survey UID], [Lookup Current Surveys].[Accordant SUS UID], [Lookup Current Surveys].Instance, [Lookup Curent Project].Sector;
Microsoft AccessSQL

Avatar of undefined
Last Comment
flemingg62

8/22/2022 - Mon
SOLUTION
als315

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
flemingg62

Thanks, that what I figured
als315

If you prepare sample DB, we can try to solve your problem
Dale Fye

use the query you have, then do something like:

SELECT Count(SQ.*) as DistinctBuildingFloors
FROM (SELECT DISTINCT Building, Floor FROM yourQuery) as SQ

Well, that wouldn't quite work, because that query is already doing a group by and counting the building/floors, but you could probably use that right most table (query) as the source for the subquery above.

All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
ASKER CERTIFIED SOLUTION
flemingg62

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question