Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
karthik_padbanaban
Constraint Violating Yak Guru
263 Posts |
Posted - 2010-04-22 : 07:28:41
|
Hi,I need to Group the data based on ID.A table data like this. A id--- -----CI 2FL 2HA 2HA 4CI 6HA 6CI 9HA 9CI 10HA 11output required :A id--- ---CI,FL,HA 2 HA 4CI,HA 6CI,HA 9CI 10HA 11 Karthikhttp://karthik4identity.blogspot.com/ |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-04-22 : 08:46:27
|
| [code]SELECT t.id,STUFF((SELECT ','+ A FROM Table WHERE id=t.id FOR XML PATH('')),1,1,'') AS AFROM (SELECT DISTINCT id FROM Table)t[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
karthik_padbanaban
Constraint Violating Yak Guru
263 Posts |
Posted - 2010-04-22 : 09:20:57
|
quote: Originally posted by visakh16
SELECT t.id,STUFF((SELECT ','+ A FROM Table WHERE id=t.id FOR XML PATH('')),1,1,'') AS AFROM (SELECT DISTINCT id FROM Table)t------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
Yes, this saved my day..!! Thanks a lot.Karthikhttp://karthik4identity.blogspot.com/ |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-04-22 : 09:40:10
|
| welcome------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|
|
|