如果我有这样的选择语句
SELECT
t.time,
<complicated computation> AS ticks,
<is it possible to access the value of the ticks row here?> as num
FROM
MyTable t;
我可以使用第2列中的计算值作为第3列计算的基础吗?
答案 0 :(得分:4)
您需要将其包装在子查询中:它将如下所示:
SELECT
i.time as time,
i.ticks as ticks,
i.ticks + 10 as num
FROM
(
SELECT
t.time as time,
5 AS ticks
FROM
MyTable t
) AS i;