title: How to pivot two of the columns in my SQL Query
body: <p>This query is almost there. The only problem I have now is that the results are not pivoting. Instead they stay in the column named Value.</p>
  <pre><code>SELECT * FROM (
      SELECT
          jD.AccountID, 
          SUM(jD.Amount) AS [Total Dollars], 
          COA.Name as COAName, 
          SUM(jD.Qty) AS QTY, 
          CONVERT(date, GETDATE()) AS Date, 
          AttributeDefinitions.Name, 
          AttributeValues.Value
      FROM
          AttributeDefinitions INNER JOIN
          AttributeCategories ON AttributeDefinitions.AttributeCategoryID = AttributeCategories.AttributeCategoryID INNER JOIN
          AttributeValues ON AttributeDefinitions.AttributeDefinitionID = AttributeValues.AttributeDefinitionID RIGHT OUTER JOIN
          JnlDetails AS jD WITH (NOLOCK) INNER JOIN
          COA ON jD.AccountID = COA.AccountID ON AttributeValues.AttributeValueGroupID = COA.AttributeValueGroupID
      WHERE
          (jD.CreateDate &gt;= GETDATE() - 2) AND 
          (jD.CreateDate &lt; GETDATE() + 1)
      GROUP BY 
          jD.AccountID, 
          COA.Name, 
          jD.Qty, 
          jD.CreateDate, 
          AttributeDefinitions.Name, 
          AttributeValues.Value
     
  ) as T1
  PIVOT
  (
     MAX([Name]) FOR Name IN ([ACCT_NO], [DEPT_ID], [GLENTRY_CLASSID],[GLENTRY_PROJECTID]
     ,[GLDIMBENEFITING_DEPARTMENT],[GLDIMFUND],[LOCATION_ID])
  ) PT
  </code></pre>