sql >> Base de Datos >  >> RDS >> PostgreSQL

combinar todas las columnas de filas en una sola columna de la tabla unida

SELECT a.parent_id, a.parent_name, STRING_AGG(b.child_name, ',') as Children
FROM
    Parent a
    INNER JOIN children b
    ON a.Id = b.ParentId
GROUP BY
    a.parent_id
    ,a.parent_name