problem in sql case statement?
select no
from shan
where account_number = '7111'
and area = 'O1139'
and ty = '1'
and ty1 = 'T'
and date = '12-AUG-10'
and code in (case 'B'
when开发者_JAVA百科 'B' then 'j01','j05'
when 'C' then 'j02','j06'
else 'j03'
end);
i need to check code value in 'j01' or 'j05' , how can i rewrite the query anyone please direct me in a right way?
select no from shan
where
account_number = '7111'
and area = 'O1139'
and ty = '1'
and ty1 = 'T'
and date = '12-AUG-10'
and ('B' = 'B' AND code in ('j01', 'j05') OR 'B' = 'C' AND code in ('j02','j06'))
case works for scalar values only.
The solution provided would be an alternative.
精彩评论