Re: [GENERAL] avg() of array values

2007-09-12 Thread Alban Hertroys
Martijn van Oosterhout wrote: avg(*) is not valid, same for sum(*) Doh! Thanks. -- Alban Hertroys [EMAIL PROTECTED] magproductions b.v. T: ++31(0)534346874 F: ++31(0)534346876 M: I: www.magproductions.nl A: Postbus 416 7500 AK Enschede // Integrate Your World //

[GENERAL] avg() of array values

2007-09-11 Thread Alban Hertroys
Hi, I'm trying to get an avg value of 2 dates (to get to the month that most part of an interval is in). I found SP's to generate rows from array values, which I figured I could use with the avg aggregate, but to my surprise: * create or replace function explode_array(in_array anyarray) returns

Re: [GENERAL] avg() of array values

2007-09-11 Thread Martijn van Oosterhout
On Tue, Sep 11, 2007 at 05:50:38PM +0200, Alban Hertroys wrote: * select avg(*) from explode_array(array[1, 3]); avg 1. (1 row) avg(*) is not valid, same for sum(*) the reaosn you get the answer you do it because postgres replaces the *

Re: [GENERAL] avg() of array values

2007-09-11 Thread Rodrigo De León
On 9/11/07, Alban Hertroys [EMAIL PROTECTED] wrote: I would have expected an avg of 2.0 and a sum of 4, where am I going wrong? This works for me: select avg(a) from explode_array(array[1, 3]) a; avg 2. (1 row) ---(end of