摘要: 下文講述case when中多條件的編寫方法,如下所示: 實驗環境:sql server 2008 R2 case when 多條件編寫方法 case when多條件編寫語法: case when 條件1 and 條件2 then '1' when 條件1 and 條件2 then '1' ...
摘要:
下文講述case when中多條件的編寫方法,如下所示:
實驗環境:sql server 2008 R2
case when 多條件編寫方法
case when多條件編寫語法:
case
when 條件1 and 條件2 then '1'
when 條件1 and 條件2 then '1'
else
end
case when 多條件編寫舉例
create table [maomao365.com] (keyId int identity, xingBie varchar(100) ) go insert into [maomao365.com] (xingbie)values('1'), ('0'),('1') ,('1'),('2') go select keyId, case when xingBie ='1' or xingBie ='2' then N'性別' when xingBie ='0' then N'未填寫!' else '' end as xingBie from [maomao365.com] go truncate table [maomao365.com] drop table [maomao365.com]