title: How to include a function in the AS part of query?
body: <p>I query the Postgres database to get statistics for the 4 last years.<br>
  However I cannot figure out the correct syntax to replace the hard-coded date
  in the <code>AS</code> part of the query with a function.</p>
  
  <p>Say: <code>date_part('year',current_date)-1</code> instead of <code>"2012"</code></p>
  
  <pre><code>SELECT * FROM crosstab('
  SELECT client,date_part (''year'',date) as SalesDate
         ,Sum(total)::integer AS Synthese
  FROM statistic
  WHERE date_part(''year'',date)&gt;date_part(''year'',current_date)-5
  AND date_part(''year'',date)&lt;date_part(''year'',current_date)
  GROUP BY client,SalesDate
  ORDER BY 1,2',
  $$VALUES 
  (date_part('year',current_date)-4),
  (date_part('year',current_date)-3),
  (date_part('year',current_date)-2),
  (date_part('year',current_date)-1)$$)
  AS ( client text, "2009" text, "2010" text , "2011" text, "2012" text);
  </code></pre>