У меня есть подзапрос, который вернет 1=1
или ISNULL(optoutflag,'0')=0
. Сейчас я пытаюсь использовать это возвращаемое значение в предложении основного запроса where
. Если я добавляю напрямую, выдает ошибку типа argument of WHERE must be type Boolean, not type text
. Ниже приведен запрос, который я использую.
select *
from ev_customer_v
where (
select *
from (select case
when a.cnt = '2' then 'ISNULL(optoutflag,\'0\')=\'0\''
when a.cnt = '0' then '1=1'
end as columns
from (
select count(*) as cnt
FROM information_schema.columns
WHERE table_name='ev_customer_v'
and column_name in ('optoutflag1','deletedataflag1')
) a
) b
)