SQLTeam.com | Weblogs | Forums

Concatenate with groupby


#1

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


#2

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