Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

use column alias in another calculation

Jimmie_MJun 7 2013 — edited Jun 7 2013
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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 5 2013
Added on Jun 7 2013
7 comments
6,535 views