Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 case problem

Author  Topic 

bilencekic
Posting Yak Master

121 Posts

Posted - 2007-05-18 : 07:36:35
hi,
i have text column named ERROR

query like this
select.....
case Error
when 'xxx' then 1
when 'yyy' then 2
end as Condition
...



when i add the where clause it doenst work.
for ex;
when i use "where Condition = 0 "
table returns all the conditions

why ?
i tried "where Condition = '0' "

it doesnt work too.



MS BLESS US

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-05-18 : 07:49:25
[code]Select * from
(select ....
case Error
when 'xxx' then 1
when 'yyy' then 2
end as Condition
...
) t
Where condition = 0[/code]

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

bilencekic
Posting Yak Master

121 Posts

Posted - 2007-05-18 : 08:28:25
arghh
no
select t.a,t.b,t.c,(select case error
when 'xxx' then 1
end as condition
where tablename.ID = t.ID
) as t,
form tablename t
inner join.....


well on the result i see the T column but when i add the
where t = 0 to the end of query
it gives error that there is no column named t




MS BLESS US
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-05-18 : 08:33:09
Post your complete query here.

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

bilencekic
Posting Yak Master

121 Posts

Posted - 2007-05-18 : 08:35:10
ok fixed.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-05-18 : 11:36:40
quote:
Originally posted by bilencekic

ok fixed.


Why dont you show us fixed query?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

mahesh_bote
Constraint Violating Yak Guru

298 Posts

Posted - 2007-05-18 : 12:02:34
quote:
Originally posted by bilencekic

arghh
no
select t.a,t.b,t.c,(select case error
when 'xxx' then 1
end as condition
where tablename.ID = t.ID
) as t,
form
tablename t
inner join.....


well on the result i see the T column but when i add the
where t = 0 to the end of query
it gives error that there is no column named t




MS BLESS US



remove comma and replce form with from

thx,

Mahesh
Go to Top of Page
   

- Advertisement -