Forums

This topic is locked

Aggregate Function/No Group By Error

Posted 07 Sep 2007 02:39:28
1
has voted
07 Sep 2007 02:39:28 Ken Dobson posted:
Has anyone else had this issue in DW? I have the following recordset that works fine in T-SQL and it also works fine when testing the recordset in DW. When trying to expand the recordset on the bindings tab to access the fields, I get the error that tells me that the LB_VisitReasons.Reason is invalid in the select list because it is not contained in an aggregate function and there is no GROUP BY clause.

RECORDSET:

SELECT TOP 100 PERCENT dbo.LB_VisitReasons.Reason, COUNT(*) AS ReasonTotal
FROM dbo.SiteVisits LEFT OUTER JOIN dbo.LB_VisitReasons ON dbo.SiteVisits.NonTrainingID = dbo.LB_VisitReasons.ID
WHERE (dbo.SiteVisits.NonTrainingID IS NOT NULL) AND (dbo.SiteVisits.DateVisited BETWEEN SD AND ED) AND (dbo.SiteVisits.EmployeeID = MyID) AND (dbo.SiteVisits.FOO = MyFOO) AND (dbo.SiteVisits.Office = MyOffice)
GROUP BY dbo.SiteVisits.FOO, dbo.SiteVisits.Office, dbo.SiteVisits.EmployeeID, dbo.LB_VisitReasons.Reason
ORDER BY ReasonTotal DESC

Thanks for any insight.

Reply to this topic