sql - Group_concat equivalent in postgresql 8.2.11 -
i using older version of postgres 8.2.11. can tell me equivalent of mysql's group_concat
postgres 8.2.11. have tried array_accum
, array_to_string
, string_agg
doesn't work in version
the "not quite duplicate" in comments should point in right direction: create own aggregate function. first you'll need non-aggregate string concatenation function, this:
create function concat(t1 text, t2 text) returns text $$ begin return t1 || t2; end; $$ language plpgsql;
then can define own aggregate version of function:
create aggregate group_concat( sfunc = concat, basetype = text, stype = text, initcond = '' );
now can group_concat
want:
select group_concat(s) t group g
i dug out of archives think should work in 8.2.
keep in mind 8.2 no longer supported might want upgrade @ least 8.4 possible.
Comments
Post a Comment