I have data in my table as following:
Author ID Book Name A1 Book1 A1 Book2 A2 Book4 A2 Book5
I want to represent the data as
A1 Book1,Book2 A2 Book3,Book5
How I can do that without using a temporary table?
I have data in my table as following:
Author ID Book Name A1 Book1 A1 Book2 A2 Book4 A2 Book5
I want to represent the data as
A1 Book1,Book2 A2 Book3,Book5
How I can do that without using a temporary table?
 
    
     
    
    This question is already asked and answered.Check the questions before you post.
Edit this code according to your column.
   Select T1.Id
    , Stuff(
        (
        Select ', ' + T2.Address
        From MyTable As T2
        Where T2.Id = T1.Id
        Order By T2.Address
        For Xml Path(''), type
        ).value('.', 'nvarchar(max)'), 1, 2, '') As Address
From MyTable As T1
Group By T1.Id
 
    
    