Re: concatenate text
| От | Michael Fuhr |
|---|---|
| Тема | Re: concatenate text |
| Дата | |
| Msg-id | 20050905020021.GA64260@winnie.fuhr.org обсуждение исходный текст |
| Ответ на | concatenate text (Sterpu Victor <victor@ambra.ro>) |
| Список | pgsql-general |
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
В списке pgsql-general по дате отправления: