Choose AS not working in interbase

work

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

adding DateDiffin Where- doesn't work

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  
+3
source share
2 answers

You can only use column aliases in GROUP BY, ORDER BY, or HAVING clauses.

Standard SQL does not allow reference to a column alias in a WHERE clause. This restriction is imposed because when the WHERE code is executed, the column value cannot yet be determined.

try it

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 

For more information, follow these links.

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

Unknown column in the Where section

+11
source
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 
0
source

Source: https://habr.com/ru/post/1793047/


All Articles