Re: [SQL] Extracting data from arrays

2009-05-18 Thread Dani CastaƱos
Thank you very much! -Mensaje original- De: Pavel Stehule [mailto:pavel.steh...@gmail.com] 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; CR

Re: [SQL] Extracting data from arrays

2009-05-18 Thread Harald Fuchs
In article <162867790905180410n670062b0ud2d7fdd0e652...@mail.gmail.com>, Pavel Stehule writes: > Hello > 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 im

Re: [SQL] Extracting data from arrays

2009-05-18 Thread Pavel Stehule
Hello 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 ---

[SQL] Extracting data from arrays

2009-05-18 Thread Dani CastaƱos
Hi all, I've this query including arrays: SELECT hour[1:5], statistics_date FROM statistics_daily WHERE statistics_date = to_date( '03/01/2008', 'DD/MM/' ) Result: hour| statistics_date +- {1800,1800,1800,1800,1800} | 2