Alias is very helpful to shorten long query in SQL.
To use Alias in the same query you can use the following method:
SELECT A,B,C*50 from (select A,B,(A+B) as C from table).
note that you can choose any column from inner-query to display it in outer-query.
but you cannot display a column in outer-query which is not exist in inner-query.
You can try this example using SCOTT schema:
select SAL,COMM,COMM_RATE *100 from (
select SAL,COMM,(COMM/SAL) as COMM_RATE from emp)
To use Alias in the same query you can use the following method:
SELECT A,B,C*50 from (select A,B,(A+B) as C from table).
note that you can choose any column from inner-query to display it in outer-query.
but you cannot display a column in outer-query which is not exist in inner-query.
You can try this example using SCOTT schema:
select SAL,COMM,COMM_RATE *100 from (
select SAL,COMM,(COMM/SAL) as COMM_RATE from emp)
No comments:
Post a Comment