I want to do something like this:
SELECT round(100*(col_a - col_b)/col_a, 1) as Foo, Foo - col_c as Bar
FROM my_table
WHERE...;
However, I get an error saying Foo
is unknown. Since Foo is derived from some calculations on a bunch of other columns, I don't want to repeat the formula again for Bar
. Any work-arounds?