0
I have a question on how I could concatenate the email column, as query below:
select * from orcam INNER JOIN ccusto as a ON orcam.Ccusto = a.Ccusto INNER JOIN grupo_email b on a.Ccusto
COLLATE SQL_Latin1_General_CP1_CI_AS = b.cc INNER JOIN grupo_resp c ON b.resp = c.id where orcam.Ccusto=0151 and anomes=201709
Who brings me the information:
Ccusto | Grupo | Anomes | Ccusto | cc | resp | id | email
0151 0452 201709 0151 0151 1 1 [email protected]
0151 0452 201709 0151 0151 1 2 [email protected]
I’m associating the column cc
according to the column Ccusto. In this way, it brings me all those responsible for CCusto
registered.
The problem, is that it is repeating to the same group for each email. What I am trying to do, is the output below
Ccusto | Grupo | Anomes | Ccusto | cc | email
0151 0452 201709 0151 0151 [email protected];[email protected]
Notice that he did not repeat the Grupo
and concatenated the email02 after the first e-mail.
The idea here is to concatenate all emails responsible for Ccusto
0151 for each group on the same line.
Personal thank you!
see if it helps: https://www.red-gate.com/simple-talk/sql/t-sql-programming/concatenating-row-values-in-transact-sql/
– Rovann Linhalis