2 tables: (only including columns that matter)
tblIPtoCountry (countrycode, country)
tblSiteVisits (sessionid, countrycode)
SProc:
Code:
sp_GET_SiteVisitsByCountry_ByDate 
@date		DATETIME
AS
SELECT tblSiteVisits.countrycode, COUNT(sessionid) AS VisitCount
FROM tblSiteVisits
WHERE CONVERT(CHAR(8),utctime, 112) = CONVERT(CHAR(8), @date, 112)
GROUP BY tblSiteVisits.countrycode
ORDER BY VisitCount DESC
I want to return the Country, as well as the Count. Can only get Country by joining with tblIPtoCountry.

but when i try to join like this:
Code:
sp_GET_SiteVisitsByCountry_ByDate
@date		DATETIME
AS
SELECT tblSiteVisits.CountryCode, tblIPtoCountry.Country, COUNT(sessionid) AS VisitCount
FROM tblSiteVisits
INNER JOIN tblIPtoCountry ON tblSiteVisits.countrycode = tblIPtoCountry.CountryCode
WHERE CONVERT(CHAR(8),utctime, 112) = CONVERT(CHAR(8), @date, 112)
GROUP BY  tblIPtoCountry.Country
ORDER BY VisitCount DESC
I get this error:
Server: Msg 8120, Level 16, State 1, Procedure sp_GET_SiteVisitsByCountry_ByDate, Line 4
Column 'tblSiteVisits.countrycode' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
I tried the same thing in many variations, but no luck.

Thanks