PostgreSQL
 sql >> Base de Dados >  >> RDS >> PostgreSQL

Postgres para buscar a lista com valores separados por vírgulas


Agregue por funcionário e use string_agg :
select
    c.employee_id,         -- or just c.* assuming employee_id is a PK
    string_agg(ce.email, ',') as emails
from root.employee c
full outer join root.employee_email ce
    on c.employee_id = ce.employee_id
group by
    c.employee_id
order by
    c.employee_id
limit 1000
offset 0;