Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Error in group by clause

Author  Topic 

kathyc
Starting Member

9 Posts

Posted - 2009-03-14 : 14:51:29
Hello

I am getting the following error in my query and don't know what I've done wrong.

Msg 8120, Level 16, State 1, Line 7
Column 'dbo.FilteredOpportunity.contactidname' is invalid in
the select list because it is not contained in either an
aggregate function or the GROUP BY clause.

Here is my code...

DECLARE @StartDate DATETIME
DECLARE @EndDate DATETIME

SET @StartDate = '1/1/2009'
SET @EndDate = '12/12/2009'

SELECT
customeridname, contactidname,
actualvalue, actualclosedate,
COUNT(customeridname) AS MyTotal

FROM dbo.FilteredOpportunity
WHERE actualclosedate BETWEEN @StartDate AND @EndDate AND statecode = 1

GROUP by customeridname
ORDER BY actualclosedate;

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2009-03-14 : 15:26:34
Use like as your other post:
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=121682
Or
Explain what exactly you are looking for?
Go to Top of Page
   

- Advertisement -