摘要:
下文講述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))goinsert into [maomao365.com](xingbie)values('1'),('0'),('1'),('1'),('2')goselect keyId,case when xingBie ='1' or xingBie ='2' then N'性別'when xingBie ='0' then N'未填寫!'else ''end as xingBie from [maomao365.com] gotruncate table [maomao365.com]drop table [maomao365.com]
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/28303.html
標籤:SQL Server
上一篇:sqlserver實作分隔字串
下一篇:SQL 數字轉為中文大寫
