Search Postgresql Archives

Re: Combining several rows

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

 



Matthias Nagl <pg@mnagl.de> writes:

> For a table like this I am looking for a query that returns a result that 
> looks this way:
> 
>     name
> -------------
> abc, def, ghi

You need something like this:

create function concat_agg_accum(varchar, varchar) returns varchar 
    as 'select $1 || '', '' || $2' 
    language sql 
    strict immutable;

create aggregate concat_agg (
    basetype = varchar, 
    stype = varchar, 
    sfunc = concat_agg_accum
);


select concat_agg(name) as name, ...

-- 
greg


---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
    (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)

[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