如何根据其他两个列的算术结果创建一个临时列?

How can I create a temporary column as the result of arithmetic from two other columns?

我想实现以下目标:

select a, 
       b,
       diff as (b-a)
from some_table;

你的语法不差,试试这个:

select a, 
       b,
       b - a as diff
from some_table;

为列添加别名的通用 ANSI 语法是:

select <expression involving columns> as <alias name>
from some_table

select a,b,a-b 不同于 some_table;