| От | 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 по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера