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 'B' then 'j01','j05'
when 'C' then 'j02','j06'
else 'j03'
end);
我需要检查'j01'或'j05'中的代码值,如何重写查询,请以正确的方式指导我?
答案 0 :(得分:0)
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'))
仅适用于标量值。
提供的解决方案将是另一种选择。