mssql sqlserver 如何编写case when 多条件呢?「建议收藏」

mssql sqlserver 如何编写case when 多条件呢?「建议收藏」摘要: 下文讲述case when中多条件的编写方法,如下所示: 实验环境:sql server 2008 R2 case when 多条件编写方法 case when多条件编写语法: case wh

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

代码100分

 

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
转载请注明出处: https://daima100.com/10821.html

(0)
上一篇 2022-12-21
下一篇 2022-12-21

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注