在 PostgreSQL 的列中连接字符串

Concatenate strings in a column in PostgreSQL

我正在尝试转换下面的 table:

id  another_id_1 another_id_2  remarks
1   34.         151.         good
2.  34.         151.         okay
3.  34.         152.         bad
4.  34.         153.         very good
5.  34          153          okay
6.  34          154          good
7.  34          155          bad

进入

another_id_1 another_id_2 remarks
34.          151.         good, okay
34.          152.         bad
34.          153          very good, okay
34.          154          good
34           155          bad

下面的 table 使用 postgresql 语句:

有什么办法可以实现吗,我试过似乎都没有用

虽然和你的数据不一致,但我觉得你想要聚合:

select another_id_1, another_id_2, 
       string_agg(remarks, ', ' order by id) as remarks
from t
group by another_id_1, another_id_2;