Search Postgresql Archives

Re: concatenate text

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

 



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.

Are you looking for an aggregate in particular or will any solution
suffice?  Here's a trivial example that works in 7.4 and later:

CREATE TABLE foo (name text);

INSERT INTO foo VALUES ('Alice');
INSERT INTO foo VALUES ('Bob');
INSERT INTO foo VALUES ('Carol');
INSERT INTO foo VALUES ('Dave');

SELECT array_to_string(ARRAY(SELECT name FROM foo), '');
  array_to_string  
-------------------
 AliceBobCarolDave
(1 row)

If you need an aggregate then search the archives; examples have
been posted before.

-- 
Michael Fuhr

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
       subscribe-nomail command to majordomo@xxxxxxxxxxxxxx so that your
       message can get through to the mailing list cleanly

[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