title: Pivot Table with varchar values
body: <p>this is the first-time I use this and I hope i will achieve this, I am getting mad. I am still a newbie about all this programming with SQL thing, I am trying to use pivot table to turn the source table in the desired output showed as below.</p>
  <p>This is my source table</p>
  <p>Here is the image, I was unable to upload it (<a href="https://i.stack.imgur.com/KDStF.jpg" rel="nofollow noreferrer">https://i.stack.imgur.com/KDStF.jpg</a>).
  <img src="https://i.stack.imgur.com/KDStF.jpg" alt="enter image description here" /></p>
  <p>But whatever I try it returns me numbers but the varchar values I would like to, as it is shown above.
  Would any of you know how to achieve it?</p>
  <p>I am using Transact SQL in Sql Server, here is my code</p>
  <pre><code>SELECT [Ques1], [Ques2]
  FROM
  (
    SELECT
      D.DocumentId,
      DA.QuestionId,
      Q.ShortText, 
      DA.[Text],
      Q.SectionId, 
      1 as [Count]
  -- ShortText is literally 'Ques1' or 'Ques2'
      FROM Document D
      INNER JOIN DocumentAnswer DA
      ON DA.DocumentId = D.DocumentId
      INNER JOIN Question Q
      ON Q.QuestionId = DA.QuestionId
      WHERE D.DeleteDate IS NULL
  ) d  
  PIVOT
  (
      Max(ShortText)
      FOR [Text] IN ([Ques1], [Ques2])
  ) p
  </code></pre>