Search Postgresql Archives

Re: concatenate text

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



David Fetter wrote:

On Mon, Sep 05, 2005 at 03:00:30AM +0300, Sterpu Victor wrote:
Can I do something like this?
SELECT sum(name) FROM table;

Where name is a text field.
I know 'sum' doesn't work, but is there another solution?
'||' is not good because it will take just 2 arguments.

Currently, you can use a custom aggregate like array_accum()
http://www.postgresql.org/docs/current/static/xaggr.html

combined with the array_to_string() like this:

SELECT array_to_string(array_accum(email), ', ') AS "emails"
FROM person_email;


Check out the "User Comments" at

http://www.postgresql.org/docs/8.0/interactive/sql-createaggregate.html

There are a couple good suggestions there that don't deal with arrays.

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux