|
|
|
SSC Journeyman
      
Group: General Forum Members
Last Login: Friday, May 17, 2013 1:15 PM
Points: 81,
Visits: 336
|
|
Hi i got a table which has data like
Table
Col1----col2----Col3 X--------1-------a X--------1--------b X--------1--------c Y--------2-------e Y--------2--------f Z--------2-------g Z--------2-------h
i should get an out put which looks like
col1---col2---col3 x------1------a,b,c y------2-------e,f z------2--------g,h
Can any one help me out with this...
Thank you
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Today @ 1:53 PM
Points: 2,984,
Visits: 4,403
|
|
tripri (8/23/2010) Hi i got a table which has data like
Table Col1----col2----Col3 X--------1-------a X--------1--------b X--------1--------c Y--------2-------e Y--------2--------f Z--------2-------g Z--------2-------h
i should get an out put which looks like col1---col2---col3 x------1------a,b,c y------2-------e,f z------2--------g,h
Can any one help me out with this...
Thank you
Is this homework? what do you got so far?
_____________________________________ Pablo (Paul) Berzukov
Author of Understanding Database Administration available at Amazon and other bookstores.
Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.
|
|
|
|
|
SSC Eights!
      
Group: General Forum Members
Last Login: Monday, May 06, 2013 2:52 AM
Points: 973,
Visits: 463
|
|
Try this....
SELECT DISTINCT c1.Col1, c1.Col2, STUFF((SELECT ',' + Col3 FROM Tablename c WHERE c.Col1 = c1.Col1 FOR XML PATH('')),1,1,'') FROM Tablename c1
|
|
|
|