Lee Hachadoorian pisze:
> Is there a function that returns the average of the elements of an
> array? I'm thinking of something that would work like the avg()
> aggregate function where it returns the average of all non-NULL
> values. Can't find anything like it in the docs, and I'd like to make
> sure I'm not missing something.
>
> Thanks,
>
>
Use unnest() ->
http://www.postgresql.org/docs/8.4/interactive/functions-array.html
# select avg(unnest) from (select unnest(ARRAY[1,2,null,3])) a; avg
--------------------2.0000000000000000
(1 row)