Thread: Re: [GENERAL] Illegal use of aggregates or non-group column in target list
Re: [GENERAL] Illegal use of aggregates or non-group column in target list
From
"G. Anthony Reina"
Date:
Jason wrote: > select target, avg(reaction_time) from data_table GROUP BY target; > > That should do it. > > -Jason. > Wow! That works great. Thanks Jason. 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? -Tony
Re: [GENERAL] Illegal use of aggregates or non-group column in target list
From
Peter Eisentraut
Date:
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