title: Date as alias names in SQL Server
body: <p>I am trying to alias few columns to date values and got stuck trying different ways.</p>
  
  <pre><code>SELECT  
     r.RET_MAIN_DSC,
     max(case when day_dt=Convert(date, getdate()-7) and EXT_SALES_AMT2&gt;0 then 'X' else '-' end) as a,
     max(case when day_dt=Convert(date, getdate()-6) and EXT_SALES_AMT2&gt;0 then 'X' else '-' end) as b,
     max(case when day_dt=Convert(date, getdate()-5) and EXT_SALES_AMT2&gt;0 then 'X' else '-' end) as c,
     max(case when day_dt=Convert(date, getdate()-4) and EXT_SALES_AMT2&gt;0 then  'X' else '-' end) as d,
     max(case when day_dt=Convert(date, getdate()-3) and EXT_SALES_AMT2&gt;0 then 'X' else '-' end) as e,
     max(case when day_dt=Convert(date, getdate()-2) and EXT_SALES_AMT2&gt;0 then 'X' else '-'  end) as f,
     max(case when day_dt=Convert(date, getdate()-1) and EXT_SALES_AMT2&gt;0 then 'X'  else '-' end) as g,
     max(case when day_dt=Convert(date, getdate()) and EXT_SALES_AMT2&gt;0 then 'X' else '-' end) as h
  FROM 
      GNL_STR_POS_ACT_1000_F POS
  JOIN 
      VC_RET_COUNTRY RET ON POS.RET_COUNTRY_ID = RET.RET_COUNTRY_ID
  JOIN 
      VC_RETAILER r on r.RET_ID=ret.RET_ID
  WHERE 
      DAY_DT BETWEEN GETDATE() - 8 AND GETDATE()
  GROUP BY  
      r.RET_MAIN_DSC
  </code></pre>
  
  <p>I am trying to alias each column to the <code>day_dt</code> value.</p>
  
  <p>For example, for column name a the alias name has to be <code>getdate()-7</code>.</p>
  
  <p>Please can someone help me?</p>
  
  <p>Thanks</p>