case式は真になるwhenが見つかったら残りは評価しない
from
case式
この評価方法は
短絡評価
、
最小評価
と呼ばれる
code:sql
declare @sex nvarchar(1);
set @sex = '2';
select
case
when @sex in ('1', '2') then '男'
when @sex = '2' then '女' -- この条件は評価されない
else 'その他'
end as 性別;
table:result
性別
男
条件は排他的に書かなくてはならない