mssql sqlserver 如何编写case when 多条件呢?

摘要:
下文讲述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]

 

posted @ 2019-11-21 22:49  Adeal2008  阅读(2834)  评论(0编辑  收藏  举报