SQLTeam.com | Weblogs | Forums

Concatenate with groupby


I have a query

select sum(qty),itemid from orders group by itemid

now is there anyway I can get a for each record a command delimited list of orderid

so I want the sum of qty but I would ike to have another collumn iwth the list of orderid from orders


Refer FOR XML method and apply https://www.simple-talk.com/sql/t-sql-programming/concatenating-row-values-in-transact-sql/