Re: [GENERAL] Illegal use of aggregates or non-group column in target list - Mailing list pgsql-general

From Peter Eisentraut
Subject Re: [GENERAL] Illegal use of aggregates or non-group column in target list
Date
Msg-id Pine.LNX.4.21.0003040353170.489-100000@localhost.localdomain
Whole thread Raw
In response to Re: [GENERAL] Illegal use of aggregates or non-group column in target list  ("G. Anthony Reina" <reina@nsi.edu>)
List pgsql-general
G. Anthony Reina writes:

> It's interesting that "select target, avg(reaction_time) from data_table
> GROUP BY target;" works but not "select target, avg(reaction_time) from
> data_table;".
>
> Doesn't the parser automatically group by the first variable returned?

The parser really doesn't know much about all of this. While you might
have a point that

    select field1, aggregate(field2) from table

doesn't have any other useful interpretation than an implied group by
field1, it's probably too much work to support such a non-SQL construct.

--
Peter Eisentraut                  Sernanders väg 10:115
peter_e@gmx.net                   75262 Uppsala
http://yi.org/peter-e/            Sweden


pgsql-general by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: [GENERAL] Median, Quartile and Percentile Aggregate Functions
Next
From: Jason Vasquez
Date:
Subject: Re: [GENERAL] Nested tables