title: change the column name while selecting from dyanamic table
body: <p>Hi I have attendence query which will generate the attendence report with using PIVOT function</p>
  
  <p>Here's the procedure : </p>
  
  <pre><code>declare  @in_date DATETIME       
  
  /*Select all the stagign entries related to promotion id and investment type id */    
    /* also only those staging daat related interface status tracking*/
  
    -- Getting all distinct dates into a temporary table #Dates
      SELECT a.date as full_date_of_attendence INTO #Dates
      FROM dbo.getFullmonth(@in_date) a
      ORDER BY a.date
  
  
  
      -- The number of days will be dynamic. So building
      -- a comma seperated value string from the dates in #Dates
      SELECT  @cols = COALESCE(@cols + ',[' + CONVERT(varchar, full_date_of_attendence, 106)
                                      + ']','[' + CONVERT(varchar, full_date_of_attendence, 106) + ']')
      FROM    #Dates
      ORDER BY full_date_of_attendence
  
  
      --select @cols
  
      ---- Building the query with dynamic dates
  
  SET @qry =
      'SELECT * FROM
      (SELECT admission_id, attendence_status , date_of_attendence
      FROM dbo.tblattendence)emp
      PIVOT (MAX(attendence_status) FOR date_of_attendence IN (' + @cols + ')) AS stat'    
  
  
  
      -- Executing the query
      EXEC(@qry)
  
      -- Dropping temporary tables
      DROP TABLE #Dates
  </code></pre>
  
  <p>here is the output of the above query::         </p>
  
  <pre><code>admission_id    01 May 2013 02 May 2013 03 May 2013
  2                NULL               1               0
  3                NULL               1               1
  4                NULL               0               0
  5                NULL               0               1
  </code></pre>
  
  <p>Here I want to change the names of the columns as <code>01,02,03......</code>
  and I want the values 1 as 'P' and 0 as 'A'</p>
  
  <p>can anyone would help me to achieve this ??</p>