I know that postgres does not have group_concat, but I want to emulate it for strings by using string_agg (or any other way that works).
I need to have the function called group_concat because of an inability to change legacy code.
How can I do this?
For what its worth, I also tried implementing group_concat using regular concat, and ran into an error there as well:
CREATE AGGREGATE group_concat (text) (sfunc = concat, stype=text)
error:
"function concat(text,text) does not exist"
group_concat()but the MySQL syntax deviates in so many areas from standard SQL and the one used by Postgres that you won't get far with keeping the existing SQL statements as they are. The first things that come to mind are date or interval literals, the strange (not to say broken) "boolean" handling in MySQL or implicit type casts.group_concat()for other types. I am talking about the huge differences in syntax between Postgres and MySQL. I can't imagine that you will succeed in keeping SQL statements written for MySQL without any changes in your code when you run that against Postgres. It simply won't work.