Re: [HACKERS] Parser bug: alias is a "non-group column"? - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: [HACKERS] Parser bug: alias is a "non-group column"?
Date
Msg-id 199905100503.BAA24000@candle.pha.pa.us
Whole thread Raw
Responses Re: [HACKERS] Parser bug: alias is a "non-group column"?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Where did we leave this?


> Given
>     create table t1 (name text, value float8);
> 
> this works:
>     SELECT name, value FROM t1 GROUP BY name, value
>     HAVING value/AVG(value) > 0.75;
> 
> but this doesn't:
>     SELECT name AS tempname, value FROM t1 GROUP BY name, value
>     HAVING value/AVG(value) > 0.75;
>     ERROR:  Illegal use of aggregates or non-group column in target list
> 
> Curiously, it's fine if the HAVING clause is omitted ... since name is
> not mentioned in the HAVING clause, I don't see the connection ...
> 
> 6.4.2 and current sources show the same behavior.
> 
>             regards, tom lane
> 
> 


--  Bruce Momjian                        |  http://www.op.net/~candle maillist@candle.pha.pa.us            |  (610)
853-3000+  If your life is a hard drive,     |  830 Blythe Avenue +  Christ can be your backup.        |  Drexel Hill,
Pennsylvania19026
 


pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: [HACKERS] ecpg fixes
Next
From: Bruce Momjian
Date:
Subject: Re: [HACKERS] "op must return bool to be used with subquery"?