title: how to pivot a table to reflect row values as columns?
body: <p>SQL returns the following table from the query:</p>
  
  <pre><code>Application  FDate        Type   Value
  -----------  ------      ----   ------
  abcd         04/15/2013  CIndex  3.00
  abcd         04/15/2013  CC     200000
  abcd         04/15/2013  MI     400
  xyz          04/15/2013  CIndex  2.50    
  xyz          04/15/2013  CC     15000    
  xyz          04/15/2013  MI     1200
  </code></pre>
  
  <p>I am trying to get the following result with the pivot:</p>
  
  <pre><code> Application  FDate        CIndex   CC     MI
  -----------  ------       ----   ----   -----
   abcd         04/15/2013  3.00   200000  400
   xyz          04/15/2013  2.50   15000   1200
  </code></pre>
  
  <p>Query so far:</p>
  
  <pre><code>SELECT * FROM
  (
    SELECT A.App_Name AS [Application],
    O.Functional_Date As FDate,
    CASE WHEN (T.TYPE_NAME LIKE 'Calculate Index') THEN 'CIndex'
    CASE WHEN (T.TYPE_NAME LIKE 'C Complexity') THEN 'CC'
    CASE WHEN (T.TYPE_NAME LIKE 'Medium Index') THEN 'MI' END TYPE,
  
  CASE WHEN (T.TYPE_NAME LIKE 'Calculate Index') THEN ROUND (V.TypeValue, 2)
  ELSE V.TypeValue END Value
  
  FROM [DBServer1].[DB_A].[dbo].TypeTab AS T, [DBServer1].[DB_A].[dbo].AppName AS A,    [DBServer1].[DB_A].[dbo].DateTab AS O, [DBServer1].[DB_A].[dbo].ValueTab AS V 
  
  WHERE T.Type_ID = V.Type_ID
        AND T.Type_index IN (0,1)... (several ANDs)
  ) src
  PIVOT
  ( SUM (Type)
  )piv
  </code></pre>
  
  <p>But this throws error. And not sure even if i fix the error the query is going to work.</p>
  
  <p>Please help. <br></p>
  
  <p>Thanks in anticipation!<br>
  Ashish</p>