My simplified query is as follows.
select CustomerName as custname from customers where custname='Hey'
It says Column custname is not found. How can I handle this?
In sql it does not throw any exception and accepts custname as a column.
(In fact my query is more like select IIF(...,...,...) as name from customers where custname='Hey' than the above one.)
Try change the column name. In many languages the "name" keyword is reserved
Edit
With the new query, try this:
You can't use calculated fields on where clause.