[GENERAL] Array operator sum array values + matching dimensions

2008-04-03 Thread Scara Maccai
create or replace function sum_elements(anyarray) returns anyelement as $$ select sum($1[i]) from generate_series(array_lower($1,1), array_upper($1,1)) g(i); $$ language sql immutable; Thank you! Anyway what I was really asking was a $ (or whatever

Re: [GENERAL] Array operator sum array values + matching dimensions

2008-04-02 Thread Scara Maccai
create or replace function sum_elements(anyarray) returns anyelement as $$ select sum($1[i]) from generate_series(array_lower($1,1), array_upper($1,1)) g(i); $$ language sql immutable; Thank you! Anyway what I was really asking was a $ (or whatever

[GENERAL] Array operator sum array values

2008-03-31 Thread Scara Maccai
Hi, is there a syntax that sums the values of an array? That is, having an array like {1,3,8},{5,6,7} something like select arr[1:2][2:3] gives {1,3},{6,7} ; what I'd like is: select arr[1$2][2$3] gives: 17 (that is, 1+3 + 6+7) If there is no such operator, would it be complicated

Re: [GENERAL] Array operator sum array values

2008-03-31 Thread Pavel Stehule
Hello On 31/03/2008, Scara Maccai [EMAIL PROTECTED] wrote: Hi, is there a syntax that sums the values of an array? That is, having an array like {1,3,8},{5,6,7} something like select arr[1:2][2:3] gives {1,3},{6,7} ; what I'd like is: select arr[1$2][2$3] gives: