简单问题:
我可以使用别名来计算吗?是
SELECT example1 / example2 AS ratio
, SQRT(ratio) AS squareroot
FROM example_table
合法且有特殊规则(在使用之前定义别名等)吗?
答案 0 :(得分:1)
不,您应该在使用前定义别名,所以要么:
select example1 / example2 as ratio
, sqrt(example1 / example2) as squareroot
from example_table
或
select ratio
, sqrt(ratio) as squareroot
from (
select example1 / example2 as ratio
from example_table
) as tbl