title: SQL merging columns where only one column differ
body: <p>I use SQL Server 2017 and have a simple query with joins that looks like this.</p>
  <pre><code>SELECT DISTINCT
      [p].[MainTitle] AS Title,
      [pe].[Name] AS JobName,
      [ea].[Label] AS Stat
  FROM
      [Project] AS [P]
  INNER JOIN 
      [ProjectExtended] AS [pe] ON [p].[ID] = [pe].[ProjectID]
  INNER JOIN 
      [ExtAttributes] AS [ea] ON [pe].[AttributeID] = [ea].[ID]
        ...
  WHERE 
      pe.date BETWEEN @start AND @end
      AND [ea].Label IN ('A', 'B', 'C')
  </code></pre>
  <p>The result right know looks like this (<code>JobName</code> is different for every <code>Title</code> but always the same for the same <code>Title</code>)</p>
  <pre><code>+-----------+----------+--------------+
  | Title     | JobName  | Stat         | 
  +-----------+----------+--------------+
  |      BAMB | asdf     |  C           | 
  |      BIRT | fdsa     |  B           | 
  |      BIRT | fdsa     |  A           |
  |      BOND | lofe     |  B           |
  +-----------+----------+--------------+
  </code></pre>
  <p>But I want it to show like this.</p>
  <pre><code>+-----------+----------+--------------+
  | Title     | JobName  | Stat         | 
  +-----------+----------+--------------+
  |      BAMB | asdf     |  C           |
  |      BIRT | fdsa     |  B, A        |
  |      BOND | lofe     |  B           |
  +-----------+----------+--------------+
  </code></pre>
  <p>I tried with different versions of <code>CONCAT</code>, <code>STRING_AGG</code> functions that you suggested in different threads, but no success. I only got to the point where it joins all the stats in last column - result was like A, B, C in every row.</p>