SELECT 
    strCodArtigo,
    SUM(fltQuantidadePend) OVER (PARTITION BY strCodArtigo),
    Lin.CA_Campo01
FROM
    Mov_Encomenda_Cab cab
INNER JOIN 
    Mov_Encomenda_Lin Lin ON Lin.strCodSeccao = cab.strCodSeccao
                          AND Lin.strCodExercicio = cab.strCodExercicio
                          AND Lin.strAbrevTpDoc = cab.strAbrevTpDoc
                          AND Lin.intNumero = cab.intNumero
INNER JOIN 
    Tbl_Tipos_Documentos tpdoc ON tpdoc.strAbreviatura = cab.strAbrevTpDoc
WHERE 
    Lin.fltQuantidadePend <> 0
    AND cab.bitAnulado = 0
    AND tpdoc.bitQuotation = 0
    AND tpdoc.intTpEntidade = 0
ORDER BY 
    strCodArtigo;
I have two rows with the same values (in strCodArtigo and fltQuantidadePend) except for the lin.CA_Campo01. I need to concatenate the strings in lin.CA_Campo01 so it becomes just 1 row, but I can't use string_agg because I have the SQL Server 2016 paid version. Every alternative to string_agg didn't work, and I can't figure out how to solve this problem
The result I am getting:
1.654.831.12 | 13.000000 | 16.05_TESTE
1.654.831.12 | 13.000000 | 16.05_TESTE1
The result I want must be like this:
1.654.831.12 | 13.000000 | 16.05_TESTE/16.05_TESTE1
pls :)
