我想实现以下目标:
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
选择 a,b,a-b 作为与 some_table 的差异;