在另一列中使用列别名

3

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

select col_1/col_2+col_3 as new_col,
       new_col+10 as new_col_2
from table
1个回答

5
您可以使用子查询来实现此功能:
select new_col, new_col + 10 as new_col_2
from (
    select col_1 / col_2 + col_3 as new_col
    from table
) t

你如何从原始表中选择所有列以及外部选择中的列,但排除内部选择子句中的列? - wipphd
@wipphd,您能否使用一些带有列的示例表格提供实际预期输出? - Arulkumar
如果它回答了你最初的问题,你可以接受这个答案 - Arulkumar

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接