proposal for a CookBook in postgresql.org
От
Gerardo Herzig
Тема
proposal for a CookBook in postgresql.org
Дата
Msg-id
4A1154A5.80608@fmed.uba.ar
Список
Дерево обсуждения
proposal for a CookBook in postgresql.org Gerardo Herzig <gherzig@fmed.uba.ar>
Re: proposal for a CookBook in postgresql.org Dave Page <dpage@pgadmin.org>
Re: proposal for a CookBook in postgresql.org Gerardo Herzig <gherzig@fmed.uba.ar>
Re: proposal for a CookBook in postgresql.org Pavel Stehule <pavel.stehule@gmail.com>
Re: proposal for a CookBook in postgresql.org Alvaro Herrera <alvherre@commandprompt.com>
Re: proposal for a CookBook in postgresql.org Pavel Stehule <pavel.stehule@gmail.com>
Re: proposal for a CookBook in postgresql.org Alvaro Herrera <alvherre@commandprompt.com>
Re: proposal for a CookBook in postgresql.org Bruce Momjian <bruce@momjian.us>
Re: proposal for a CookBook in postgresql.org Alvaro Herrera <alvherre@commandprompt.com>
Re: proposal for a CookBook in postgresql.org Bruce Momjian <bruce@momjian.us>
Re: [DOCS] proposal for a CookBook in postgresql.org Alvaro Herrera <alvherre@commandprompt.com>
Re: [DOCS] proposal for a CookBook in postgresql.org Bruce Momjian <bruce@momjian.us>
I just saw a beatifull answer from Pavel, as an answer to this question: """ I'm just wondering if there's some way to retrieve the hour column as the > sum of the array values... Just like this: > > hour | statistics_date > ----------------------------+----------------- > 9000 | 2008-01-03 """ With this function: """ postgres=# create or replace function sum_items(bigint[]) returns bigint as $$ select sum($1[i])::bigint from generate_series(array_lower($1,1), array_upper($1,1)) g(i)$$ language sql immutable; CREATE FUNCTION Time: 2,510 ms postgres=# select sum_items(array[1,2,3,4]); sum_items ----------- 10 (1 row) """ I think this is a good time to propose some kind of CookBook, to preserve this kind of answers. Gerardo
В списке pgsql-sql по дате отправления