views:

103

answers:

1

I am trying to create a series of queries in Access that count the number of clients of each ethnicity in each of 77 counties.

Here is SQL code for one of my queries that I'm trying to do this for...

SELECT [ClientsByCounty-Asian].County, [ClientsByCounty-Asian].CountyName, Count([ClientsByCounty-Asian].Asian) AS CountOfAsian
FROM [ClientsByCounty-Asian]
GROUP BY [ClientsByCounty-Asian].County, [ClientsByCounty-Asian].CountyName;

This query returns only 16 of 77 counties. I need it to display all 77 counties even when the result is zero and there are no records.

How can I get it to display the other 61 counties?

+6  A: 

Assuming your 77 counties are stored in table called Counties:

SELECT  c.CountyName, COUNT([ClientsByCounty-Asian].County)
FROM    Counties c
LEFT JOIN
        [ClientsByCounty-Asian]
ON      [ClientsByCounty-Asian].County = c.County
GROUP BY
        c.County, c.CountyName
Quassnoi
I changed Counties to the table name I am using in the database but it wouldn't work. I am not too knowledgeable about SQL, so forgive me for asking but what is "c." Thanks for your help :)
`c` is the alias for table `Counties` (or whatever is the right name) so that you don't have to type it each time. Could you please post the error text?
Quassnoi
It works! Thank you! Sorry, I had a typo the first time, didn't see it til now. Thank you so much, you are awesome! :)