sql server 2008 - I need help to bring following output in SQL Query -


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

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -