use column alias in another calculation
Database:Oracle Database 11g Enterprise Edition Release 11.2.0.3.0
Is there a way to use a column alias in an another calculation within the
same query? Since I am using some long and complex logic to compute total1
and total2, I don't want to repeat the same logic to compute the ratio of
those two columns. do you have any suggestion other than nested sub-query or view?
select
total1 = sum(case(long complex logic)),
total2 = sum(case(another long complex logic)),
ratio = total1/total2
thanks in advance