Using GROUP BY you must include all columns returned by the query which are
not aggregates (e.g. SUM, COUNT, MIN).
e.g.
SELECT
foo,
bar,
blah,
count(foobar) as count_foobar
FROM
table
GROUP BY
foo, bar, blah;
If you remove any of the columns from the GROUP BY clause you will receive
the error you mentioned in your post.
HTH,
-dhs
At 04:17 PM 12/6/01 -0500, you wrote:
>I'm using SQL Server 2000.
>I wrote query using the GROUP BY clause, but an error gets thrown saying the
>columns are
>"invalid in the select list because it is not contained in either an
>aggregate function or the GROUP BY clause"
>
>I did some digging and found something called the "GROUP BY Support
>Property"
>I'm not sure, but it looks like I can change the behavior of the GROUP BY
>clause.
>Does anyone know if this is true, and how do I do it?
>Else, why is the GROUP By clause throwing me the error?
>Matt
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Get the mailserver that powers this list at http://www.coolfusion.com
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists