gpt4 book ai didi

sql - 访问select语句中的上一个“合成”列

转载 作者:行者123 更新时间:2023-12-03 18:29:46 25 4
gpt4 key购买 nike

如果我有这样的选择语句

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列中计算的基础吗?

最佳答案

您需要将其包装在子查询中:它看起来像这样:

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;

关于sql - 访问select语句中的上一个“合成”列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21884917/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com