Subject Re: Why won't Group By work?
Author Svein Erling Tysvær
Hi Adrian!

Of course you get an error, the group by has to contain all fields
that you simply select - all other fields returned must be an
aggregate function. Suppose you had two separate values for Rainfall
within the same RainfallZone, which of the two should the query
return? And even if you only have one, Firebird cannot know that at
prepare time. Hence, you either have to do

Select * from Rainfall
Group by RainfallZone, Rainfall, RainfallDate, Rainfallid

or something like

Select RainfallZone, sum(Rainfall), count(distinct RainfallDate),
max(Rainfallid)
from Rainfall
Group by RainfallZone

Set

--- In firebird-support@yahoogroups.com, "Adrian Wreyford" wrote:
> I have a table Rainfall with fields:
>
> Rainfallid
> RainfallZone
> Rainfall
> RainfallDate
>
> Select * from Rainfall
>
> Group by Rainfallzone
>
> Get Error:
>
> Invalid expression in the select list(Not contained in either an
> aggregate function or group by clause)