I have a simple table
CREATE TABLE a(
id int IDENTITY(1,1) NOT NULL,
x varchar(50)
)
I found that following query works
select cast (id as varchar(3))+cast (x as varchar(3)) c from a
where cast (id as varchar(3))+cast (x as varchar(3))='1a'
but this does not work
select cast (id as varchar(3))+cast (x as varchar(3)) c from a
where c='1a'
Does any one knows why is that? Please not that for some reason I don't want to use
where id=1 and x ='a'