Array operator "sum array values"

From: Scara Maccai <m_lists(at)yahoo(dot)it>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Array operator "sum array values"
Date: 2008-03-31 15:08:37
Message-ID: 433303.6094.qm@web28106.mail.ukl.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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 adding it to postgres?
I mean: is the "[:]" operator an internal thing (the parser "knows" about it) or is it just like any other operators that can be added ?

___________________________________
Scopri il Blog di Yahoo! Mail: trucchi, novità, consigli... e la tua opinione!
http://www.ymailblogit.com/blog/

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Pavel Stehule 2008-03-31 15:29:25 Re: Array operator "sum array values"
Previous Message Steve Crawford 2008-03-31 14:45:22 Re: Survey: renaming/removing script binaries (createdb, createuser...)