RE: error 8120 not contained aggregate function error

From: Mal .mullerjannie_at_hotmail.com> (.mullerjannie_at_hotmail.com)
Date: 10/06/04


Date: Wed, 6 Oct 2004 09:23:05 -0700

GROUP BY Clause
Specifies the groups into which output rows are to be placed and, if
aggregate functions are included in the SELECT clause <select list>,
calculates a summary value for each group. When GROUP BY is specified, either
each column in any non-aggregate expression in the select list should be
included in the GROUP BY list, or the GROUP BY expression must match exactly
the select list expression.

>From SQL helpfiles

"Josema" wrote:

> Hi to all,
>
> Im getting an error 8120:
> Column <column name> is invalid in the select list because it is not
> contained in either an aggregate function or the GROUP BY clause.
>
> In my procedure i want to select from two tables CCList and CCThemes some
> values, and all group by CCList.CalculationTheme
>
> CREATE PROCEDURE dbo.CC_GetCCByTheme
> @ThemeID int
> AS
> Select CCList.CalculationID, CCList.CalculationName, CCThemes.ThemeName,
> CCList.CalculationURL, CCList.CalculationDate, CCThemes.ThemeImage,
> CCList.CalculationClosed
>
> from CCList inner join CCThemes on CCThemes.ThemeID=CCList.CalculationTheme
>
> where CCList.CalculationTheme=@ThemeID Group By CCList.CalculationTheme
>
>
> Why this error its returning?
>
> --
> Thanks
> Regards.
> Josema



Relevant Pages

  • RE: Any good T-SQL quick reference recommended?
    ... The full syntax of the SELECT ... SELECT Clause ... Specifies the columns to be returned by the query. ... Specifies that duplicate rows can appear in the result set. ...
    (microsoft.public.sqlserver.programming)
  • Re: top n problem
    ... Delbert Glass wrote: ... If the query has no ORDER BY clause, the order of the rows is arbitrary. ... "A car burns fuel." ... >n specifies how many rows are returned. ...
    (microsoft.public.sqlserver.programming)
  • Re: Multiple rows to one row
    ... add a GROUP BY clause and use the CONCATENATE set function in ... the SELECT clause. ... SQL Aggregate Functions ...
    (microsoft.public.access.queries)
  • Re: top n problem
    ... >to be output from the query result set. ... >ordered by the ORDER BY clause are output. ... >Specifies that additional rows be returned ... does not mean UNION without ALL is undefined. ...
    (microsoft.public.sqlserver.programming)
  • [Info-ingres] Wrong results returned from outer join
    ... " Outer joins specified in the from clause are not the same as joins ... while the where clause specifies restrictions to be applied to the sources ... Still the script returns all 2 rows. ... ON COMMIT PRESERVE ROWS WITH NORECOVERY ...
    (comp.databases.ingres)