I have a table and I\'d like to pull one row per id with field values concatenated.
In my table, for example, I have this:
TM67 | 4 | 32556 TM67 | 9
My sugestion in postgresql
SELECT cpf || ';' || nome || ';' || telefone FROM ( SELECT cpf ,nome ,STRING_AGG(CONCAT_WS( ';' , DDD_1, TELEFONE_1),';') AS telefone FROM ( SELECT DISTINCT * FROM temp_bd ORDER BY cpf DESC ) AS y GROUP BY 1,2 ) AS x