Re: Average of Array?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Average of Array?
Дата
Msg-id 5109.1277483340@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Average of Array?  (Lee Hachadoorian <lee.hachadoorian@gmail.com>)
Список pgsql-sql
Lee Hachadoorian <lee.hachadoorian@gmail.com> writes:
> 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.

You could unnest() the array and then apply the aggregate to the result.
unnest() is only built in in 8.4 and later, but it's not terribly hard
to write your own in previous versions.
        regards, tom lane


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

Предыдущее
От: Lee Hachadoorian
Дата:
Сообщение: Average of Array?
Следующее
От: Pavel Stehule
Дата:
Сообщение: Re: Average of Array?