Merge multiple rows into one column without duplicates

后端 未结 4 772
轻奢々
轻奢々 2021-02-01 02:44

I am working on a query that will collect data from a table and display the data for a report.

The data looks like this:

Player Score
001      10
001           


        
4条回答
  •  忘了有多久
    2021-02-01 03:27

    UPDATE AllNews 
        SET ArticleSource = pp.[NewsText]
      FROM AllNews AS an
      INNER JOIN (  select t1.Id,
      stuff((SELECT distinct '.' + t2.[Text]
               FROM NewsPhotos t2
               where t2.NewsId = t1.Id
               FOR XML PATH('')),1,1,'') as [NewsText]
                 from AllNews t1
                 group by t1.Id) as pp
      ON pp.Id = an.Id
    

提交回复
热议问题