标签: sql oracle oracle11g alias
是否可以执行select 1 as foo, foo+1 from dual
select 1 as foo, foo+1 from dual
这会返回ERROR at line 1: ORA-00904: "FOO": invalid identifier
ERROR at line 1: ORA-00904: "FOO": invalid identifier
我有一个冗长的计算组成一个列,我希望能够在差异列中轻松使用该值进行计算
答案 0 :(得分:4)
您无法直接使用别名。一种方法是使用派生表:
SELECT foo, foo+1 FROM (SELECT 1 AS foo FROM dual) AS T