Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Another Join Statement please??? Help. 1

Status
Not open for further replies.

qajussi

Programmer
Mar 22, 2004
236
US
Hi!

Trying to write a SQL statement to get the list of number of companies group by Country.

TblCountry
CountryID
CountryName

TblCompany
CompanyID
CountryID
CompanyName

I want to get a table with

CountryName Number of Company


I got this far,
SELECT TblCompany.CountryID, Count(TblCompany.CompanyID)
FROM TblCompany group by CountryID

which gives me the
CountryID number of company.


Can you help??
Thanks millions.
 
SELECT B.CountryName, Count(A.CompanyID)
FROM TblCompany A INNER JOIN TblCountry B ON A.CountryID = B.CountryID
GROUP BY B.CountryName

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thank you very much PHV.
It looks so simple when you have done it.

Qajussi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top