In PostgreSQL, what is the best way to call the same function multiple times in the same query?
Example:
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
Where sum_one() and sum_two() are functions. I repeat the call of sum_one() and sum_two(). This will slow down queries in large databases.
I want to avoid the following statement.
(sum_one(a.id )+sum_two(a.id)) AS "Sum_three"
How can I do it that in PostgreSQL?