当前位置: 移动技术网 > IT编程>数据库>MSSQL > mssql sqlserver 如何编写case when 多条件呢?

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

2019年11月22日  | 移动技术网IT编程  | 我要评论

尤勒斯的驱魔仪式,股票什么时候开市,巾帼枭雄之义海云天

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

 

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网