sql server 2008 - I need help to bring following output in SQL Query -
this question has answer here:
please sql query solve following issue.
i have table input values - column header x , y
x | y ------------------- 1 | a1 1 | a2 2 | a3 2 | a4 2 | a2 i need output this
x | y ---------- 1 |a1,a2 2 |a3,a4,a2 please advice!
select nto.x, stuff((select cast(',' varchar(max)) + nti.y mytable nti nti.x = nto.x xml path('')), 1, 1, '') y mytable nto group nto.x
Comments
Post a Comment