Solved

How do I sum a count, access db, sql query

Posted on 2008-06-21
2
694 Views
Last Modified: 2008-06-22
I use the query below to tell me how many unique custName entries there are for each location.

SELECT Location, Team, sum(EffectiveRevenueReal), COUNT(custName) AS DistinctNo From vwResults6 WHERE ressource=0 group by Location, Team ORDER BY COUNT(custName) DESC

I now need to sum a grand total of all of the unique custName counts.  I have tried
SELECT SUM(c) FROM (SELECT Location, ressource, Count(custName) AS c FROM vwResults6 WHERE ressource=0 GROUP BY Location, ressource) As b

However, when I try to print b, I get the error:
Item cannot be found in the collection corresponding to the requested name or ordinal.
0
Comment
Question by:hologosesh
2 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 250 total points
ID: 21838372
the "as b" names the subquery, and not the sum(c) expression...
SELECT SUM(c) as b FROM (SELECT Location, ressource, Count(custName) AS c FROM vwResults6 WHERE ressource=0 GROUP BY Location, ressource) As subquery

Open in new window

0
 

Author Comment

by:hologosesh
ID: 21841707
Great, thanks.  Works perfectly.  
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

919 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

20 Experts available now in Live!

Get 1:1 Help Now