IS it possible to count...

S

SF

Hi,

I have the following result set...

District Commune
D1 C1
D1 C2
D2 C1
D3 C1

I want to count how many district and commune, so I create a query below:

SELECT Count(tblDistricts.Di_District_e) AS CountOfDi_District_e,
Count(tblCommunes.Cn_Commune_e) AS CountOfCn_Commune_e
FROM tblDistricts INNER JOIN tblCommunes ON tblDistricts.Di_DistrictID =
tblCommunes.Cn_DistrictID;


I found that # of district and # of commune are equal (which is wrong
because there is onle 3 dsitricts and 4 communes)

Could someone advice?

SF
 
J

John Nurick

Hi SF,

I've used the Customers table in the Northwind sample database as a
'stand-in', with Countries corresponding to Districts and Cities to
Communes.

This gets you the number of countries:
SELECT COUNT(*) As NumCountries
FROM (SELECT DISTINCT Country FROM Customers);
and this the number of cities:
SELECT COUNT(*) As NumCities
FROM (SELECT DISTINCT City, Country FROM Customers);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Count problem 1
Suppressing display of group? 2
Help with table structure 1
help with Code 1
Adding values in to table for appropriate fields only 5
Help with field 2
need help with query 3
function 4

Top