How to concatenate strings of a string field in a PostgreSQL 'group by' query?

前端 未结 14 1418
北荒
北荒 2020-11-22 02:37

I am looking for a way to concatenate the strings of a field within a group by query. So for example, I have a table:

ID   COMPANY_ID   EMPLOYEE
1    1               


        
14条回答
  •  忘了有多久
    2020-11-22 03:00

    Use STRING_AGG function for PostgreSQL and Google BigQuery SQL:

    SELECT company_id, STRING_AGG(employee, ', ')
    FROM employees
    GROUP BY company_id;
    

提交回复
热议问题