sql >> Base de Datos >  >> RDS >> Sqlserver

CÓMO obtener el valor CSV para el siguiente escenario

select AccountNumber, 
       stuff((select ',' + Product 
                  from YourTable t2 
                  where t2.AccountNumber = t1.AccountNumber 
                  order by Product 
                  for xml path('')),1,1,'') as ProductString
    from YourTable t1
    group by AccountNumber