What's the equivalent for LISTAGG (Oracle database) in PostgreSQL?

前端 未结 2 557
终归单人心
终归单人心 2020-12-20 11:35

I have to replace the Oracle driver with the newest PostgreSQL. PostgreSQL doesn\'t know the function LISTAGG. I have to concat values by comma separated. What\

2条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-20 12:31

    From Postgres 9.0 or later, I believe you could do something like this:

    SELECT c_id, STRING_AGG(c_grp_id, ',' ORDER BY c_grp_id) AS group_ids 
    FROM c_grp_at 
    GROUP BY c_id
    

提交回复
热议问题