1
Jonathan I found a cool example of this site https://social.msdn.microsoft.com/Forums/sqlserver/pt-BR/6177bd7a-e2fc-46f4-9646-8fd1480cf14b/concatenar-valores-de-linhas-em-uma-coluna?forum=520
I have the following table:
Code Customer Product 1 Jorge floor 1 Jorge door 1 Jorge faucet
I need the result of this select to stay like this:
Code Customer Product 1 Jorge floor;door;tap
-- Concatenating
SELECT CODIGO,
CLIENTE,
COALESCE(
(SELECT CAST(PRODUTO AS VARCHAR(10)) + ';' AS [text()]
FROM TABELA AS O
WHERE O.CODIGO = C.CODIGO
and O.CLIENTE = C.CLIENTE
ORDER BY CODIGO
FOR XML PATH(''), TYPE).value('.[1]', 'VARCHAR(MAX)'), '') AS Produtos
FROM TABELA AS C
GROUP BY CODIGO,CLIENTE;
Also try with listagg https://docs.oracle.com/cd/E11882_01/server.112/e41084/functions089.htm#SQLRF30030
– Motta