From: | Scara Maccai <m_lists(at)yahoo(dot)it> |
---|---|
To: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
Cc: | pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Array operator "sum array values" + matching dimensions |
Date: | 2008-04-02 08:33:32 |
Message-ID: | 338956.15862.qm@web28109.mail.ukl.yahoo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
> 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 other symbol) in place of ":" for sum, that is a notation like
myarray_col[12$16]
would give the sum of all values from myarray_col[12] to myarray_col[16]
Anyway, I was reading that multidimensional arrays must have matching dimensions (that is, they can't be, for example, [5][9]).
Is this right? Why is that?
Thank you
___________________________________
Scopri il Blog di Yahoo! Mail: trucchi, novità, consigli... e la tua opinione!
http://www.ymailblogit.com/blog/
From | Date | Subject | |
---|---|---|---|
Next Message | postgre | 2008-04-02 09:20:18 | Re: [GENERAL] postgreSQL multithreading |
Previous Message | Greg Smith | 2008-04-02 08:32:42 | Re: simple update queries take a long time - postgres 8.3.1 |