Re: Average of Array?

Поиск
Список
Период
Сортировка
От Ireneusz Pluta
Тема Re: Average of Array?
Дата
Msg-id 4C2504A3.4090502@wp.pl
обсуждение исходный текст
Ответ на Average of Array?  (Lee Hachadoorian <lee.hachadoorian@gmail.com>)
Список pgsql-sql
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)


В списке pgsql-sql по дате отправления:

Предыдущее
От: Tim Landscheidt
Дата:
Сообщение: Re: enforcing constraints across multiple tables
Следующее
От: Frank Bax
Дата:
Сообщение: How do I remove selected words from text field?