So I have a command where for example
SELECT something, string_agg(other, ';') FROM table
GROUP BY something HAVING COUNT(*)>1;
but I don’t know how to separate in two columns, because it doesn’t see string_agg as a column.
This is my original
something | other |
--------+--------+
example | yes, no |
using | why, what |
and I would like this please
something | other | new
--------+--------+------
example | yes | no
using | why | what
3
Answers
We can use regular expressions here:
I would aggregate this into an array:
Alternative: Just use split_part() function. I combined with trim() function to remove leading/trailing spaces. (see demo)