title: Group By in stored procedure error
body: <p>I created this stored procedure which is basically to return a list of offices with the type of activities that happen within each office. The results i reported to reportviewer but i noticed that for each activity return it creates a table - so i can have 5 different tables each with its own activity but all happen in the same office. I want the report to be a table for each office which will contain as many activites as there are for each office. So i thought that if i grouped in my stored procedure my results will be as what i want but i am getting column error saying: "...is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause."</p>
  
  <p>I am not sure how to go about that but here is my select, from, where, group by statements: </p>
  
  <pre><code>SELECT 
              O.OfficeId,
              O.OfficeName AS Office,
              HT.Description AS HearingType,
              H.HearingDate AS HearingDate,
              CR.Description AS Court,
              CT.[Description]AS CaseType
      FROM Activity H
      INNER JOIN ActivityEntry HE ON H.ActivityEntryId = HE.ActivityEntryId
      INNER JOIN ActivityType HT ON H.ActivityTypeId = HT.ActivityTypeId
      INNER JOIN [Case] C ON H.CaseId = C.CaseId
      INNER JOIN [Office] O ON HE.CreatedByOfficeId = O.OfficeId
      INNER JOIN [User] U ON C.CreatedByUserId = U.UserId
      LEFT OUTER JOIN CaseType CT ON C.CaseTypeId = CT.CaseTypeId
      LEFT OUTER JOIN Court CR ON C.CourtId = CR.CourtId
      WHERE .dbo.DateOnly(HE.HearingDate)BETWEEN @BeginDate AND @EndDate
      GROUP  BY
              O.OfficeId,
              O.OfficeName,
              HT.Description
      ORDER BY O.OfficeId, HT.Description
  </code></pre>