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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Help with error message

Author  Topic 

jeanh
Starting Member

20 Posts

Posted - 2004-04-10 : 12:51:53
What exactly is the syntax parser telling me when I get a message like this:

Column 'xxxxxxx' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.

I seem to get this a lot, even when it appears that the column is used in the aggregate function and sometimes even in the group by clause. I know I'm missing something obvious here, it just isn't jumping out at me. (Sorry I'm somewhat new to SQL programming -- but once I get it you won't have to tell me again).

Jean


Jean Holland

derrickleggett
Pointy Haired Yak DBA

4184 Posts

Posted - 2004-04-10 : 12:54:49
An aggregate isn't SUM(SELECT xxxxx WHEN date = 'this')

An aggregate is a directly aggregated column such as MAX(this), MIN(this), etc, etc.

If you have "any" column aggregated, the rest of the columns in the select statement must be in your GROUP BY clause, even if they are in the SELECT clause AS 'SUM(SELECT xxxxx WHEN date = 'this') AS col1'.

Make sense?


MeanOldDBA
derrickleggett@hotmail.com

When life gives you a lemon, fire the DBA.
Go to Top of Page

jeanh
Starting Member

20 Posts

Posted - 2004-04-10 : 13:21:20
Thanks Derrick, You're right, I did not understand the term 'aggregate' correctly. Now I will take your example on the T-SQL forum and see if I've learned anything!

Jean Holland
Go to Top of Page
   

- Advertisement -