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 |
|
micnie_2020
Posting Yak Master
232 Posts |
Posted - 2011-11-18 : 01:15:25
|
| Dear ALl,I have Ref Sub-Ref Type OP13346 OP13346/1 CustServ OP13346 OP13346/2 Counter OP13346 OP13346/3 Serv OP13346 OP13346/4 CustServ OP13346 OP13346/5 Serv OP13347 OP13347/2 Cust OP13347 OP13347/3 Cust I want concanate the Type based on Ref#Ref Sub-Ref Type ConcanateTypeOP13346 OP13346/1 CustServ CustServ,Counter,ServOP13346 OP13346/2 Counter CustServ,Counter,ServOP13346 OP13346/3 Serv CustServ,Counter,ServOP13346 OP13346/4 CustServ CustServ,Counter,ServOP13346 OP13346/5 Serv CustServ,Counter,ServOP13347 OP13347/2 Cust CustOP13347 OP13347/3 Cust CustPlease Advise.Thank you.Regards,Micheale |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-11-18 : 01:33:14
|
| [code]SELECT *,STUFF((SELECT ',' + Type FROM table WHERE Ref = t.Ref ORDER BY [Sub-Ref] FOR XML PATH('')),1,1,'') AS ConcatenateTypeFROM Table t[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|
|
|