Re: avg() of array values - Mailing list pgsql-general

From Martijn van Oosterhout
Subject Re: avg() of array values
Date
Msg-id 20070911160324.GC29496@svana.org
Whole thread Raw
In response to avg() of array values  (Alban Hertroys <alban@magproductions.nl>)
Responses Re: avg() of array values
List pgsql-general
On Tue, Sep 11, 2007 at 05:50:38PM +0200, Alban Hertroys wrote:
> *> select avg(*) from explode_array(array[1, 3]);
>           avg
> ------------------------
>  1.00000000000000000000
> (1 row)

avg(*) is not valid, same for sum(*) the reaosn you get the answer you
do it because postgres replaces the * with a 1, whic doesn't change the
fact that the query is wrong.

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

Attachment

pgsql-general by date:

Previous
From: "Dmitry Koterov"
Date:
Subject: Sthange things happen: SkyTools pgbouncer is NOT a balancer
Next
From: "Rodrigo De León"
Date:
Subject: Re: Question about a query with two count fields