Re: avg() of array values

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Alban Hertroys <alban(at)magproductions(dot)nl>
Cc: Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Re: avg() of array values
Date: 2007-09-11 16:03:24
Message-ID: 20070911160324.GC29496@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)svana(dot)org> http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Rodrigo De León 2007-09-11 16:03:39 Re: Question about a query with two count fields
Previous Message Dmitry Koterov 2007-09-11 16:02:34 Sthange things happen: SkyTools pgbouncer is NOT a balancer