Following up on Kev's answer, using the Postgres docs:
First, create an array of the elements, then use the built-in array_to_string
function.
CREATE AGGREGATE array_accum (anyelement)
(
sfunc = array_append,
stype = anyarray,
initcond = '{}'
);
select array_to_string(array_accum(name),'|') from table group by id;