I have the following sql query:
SELECT (SELECT ...) AS X, (SELECT ...) AS Y from my_table
'X' is quite hard to compute, and it's used as an input for computing Y. However, if I try to reference X within the query that computes Y or even within the main query I get the following error message:
Error: column "X" does not exist
Is there any way to reference X once it is computed? I really don't want to compute it twice, as this seems very inefficient.