Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can i reuse an alias column, in a same select statement? 1

Status
Not open for further replies.

lgf

Programmer
Jul 10, 2001
2
ES
I wish to execute the following SQL statement:

select
round(col1 * 2) result_col1,
(result_col1 - 2) col2
from table_test


The result is: >Invalid column name

I don't want to use an another view or any object else...

I just want to reuse a column alias...

Thanks a lot for your help.... It's very important for me.

Thanks.
 
You can try this way.

select
round(col1 * 2) result_col1,
(round(col1 * 2) -2) col2
from table_test

Hope this help.
 

Or you can also make use of this, embedded query:

SELECT result_col1,
(result_col1 - 2) col2
FROM ( select round(col1 * 2) result_col1,
from table_test );



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top