I am using a simple select
statement and creating a column using a CONCAT
function and labeling the column as Filter
.
Why is the new column not being recognized?
Error message states
Invalid Column Name - Filter
I am using a simple select
statement and creating a column using a CONCAT
function and labeling the column as Filter
.
Why is the new column not being recognized?
Error message states
Invalid Column Name - Filter
You can't refer to column aliases in the where
clause as the where
is processed before the alias is materialised.
There are several workarounds, and assuming SQL Server you can do
select *
from table t
cross apply (values(concat(columna,columnb)))c([filter])
where [filter]='something'
Also note that the performance won't be great on large data sets since this criteria is non-sargable