Sqlserver
 sql >> Database >  >> RDS >> Sqlserver

COME ottenere il valore CSV per lo scenario seguente

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