作品
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
答案 0 :(得分:11)
您只能在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
有关详情,请浏览这些链接
答案 1 :(得分:0)
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