I get an error on the following query. What seems to be the problem?
DECLARE @fromdt AS datetime
DECLARE @todt AS datetime
SET @fromdt = '7/1/2014'
SET @todt = '7/31/2014'
select * from tblOrgRegistrations as r
JOIN tblOrgHours as h
ON h.RegID = r.regid
Where r.AgencyID = 74 And (h.ActivityDate >= @fromdt And h.ActivityDate <= @todt)
Group By r.Agency
Msg 8120, Level 16, State 1, Line 5
Column 'tblOrgRegistrations.RegID' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.