在另一列中使用列别名



我想在 select 子句中使用别名列作为另一列。

select col_1/col_2+col_3 as new_col,
       new_col+10 as new_col_2
from table

您可以使用子查询来实现此目的:

select new_col, new_col + 10 as new_col_2
from (
    select col_1 / col_2 + col_3 as new_col
    from table
) t

最新更新