Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Queries / November 2007

Tip: Looking for answers? Try searching our database.

IS it possible to count...

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
SF - 21 Nov 2007 01:30 GMT
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
John Nurick - 21 Nov 2007 07:08 GMT
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);

>Hi,
>
[quoted text clipped - 19 lines]
>
>SF

--
John Nurick - Access MVP
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.