gpt4 book ai didi

sql - 选择 AS 在 interbase 中不起作用

转载 作者:行者123 更新时间:2023-12-03 15:41:17 24 4
gpt4 key购买 nike

作品

select payeeid, EXTRACT(WEEKDAY FROM checkdate) as DOW, 
(bankcleared - checkdate) as DateDiff
from Master
where (bankcleared is not null)
order by payeeid, DOW, DateDiff

DateDiff 添加到 Where - 不起作用

select payeeid, EXTRACT(WEEKDAY FROM checkdate) as DOW, 
(bankcleared - checkdate) as DateDiff
from Master
where (bankcleared is not null) AND (DateDiff >= 1)
order by payeeid, DOW, DateDiff

最佳答案

您只能在 GROUP BY、ORDER BY 或 HAVING 子句中使用列别名。

标准 SQL 不允许您在 WHERE 子句中引用列别名。施加此限制是因为执行 WHERE 代码时,列值可能尚未确定。

试试这个

select payeeid, EXTRACT(WEEKDAY FROM checkdate) as DOW, 
(bankcleared - checkdate) as DateDiff
from Master
where (bankcleared is not null) AND ((bankcleared - checkdate)>= 1)
order by payeeid, DOW, DateDiff

有关更多信息,请访问这些链接

Can you use an alias in the WHERE clause in mysql?

Unknown Column In Where Clause

关于sql - 选择 AS 在 interbase 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5042094/

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