title: PostgreSQL: best way to call the same function multiple times in one query?
body: <p>In PostgreSQL, what is the best way to call the same function multiple times in the same query?</p>
  
  <p>Example:</p>
  
  <pre><code>SELECT a.id, 
         sum_one(a.id) AS "Sum_one",
         sum_two(a.id) AS "Sum_two",
         (sum_one(a.id )+sum_two(a.id)) AS "Sum_three"
    FROM a
  </code></pre>
  
  <p>Where <code>sum_one()</code> and <code>sum_two()</code> are functions. I repeat the call of <code>sum_one()</code> and <code>sum_two()</code>. This will slow down queries in large databases.</p>
  
  <p>I want to avoid the following statement.</p>
  
  <pre><code>(sum_one(a.id )+sum_two(a.id)) AS "Sum_three"
  </code></pre>
  
  <p>How can I do it that in PostgreSQL?</p>