I have this query
insert into A
select 1,99,'ABC'
union
select 2,99,'5-0-0'
go
insert into B
select 1, 'ONE'
union
select 2, 'TWO'
;with dt as (
select cast(replace(CODEVALUE,'-','') as int) VAL
from A
join B on B.CODEID=A.CODEID and B.CODENAME='TWO' and A.PRJID=99
)
select MSG from (
select case when VAL>25 then 'BRAVO' end MSG from dt
) q
where MSG is not null
I expected to return MSG, not error
But if I remove
where MSG is not null
it works
1