首页 > 技术文章 > if 和case

shuibi 2017-03-16 18:08 原文

select case 'O'
when 'O' then (1*5-6)
when 'C' then (1*5-6)
when 'EC' then (1*5-6)
--else null
--end
--case @loanStatus
when 'IL' then

case when (15-100-80+12)>0 then 15-100 else 0 end
--if (15-100-80+12)>0 then (15-100) else 0 end


end

declare @loanStatus varchar
set @loanStatus='O'
declare @aa int
set @aa=1
if @loanStatus='O'
set @aa=1*5-6
if @loanStatus='C'
set @aa=1*5-6
if @loanStatus='EC'
set @aa=1*5-6
--else null
--end
--case @loanStatus
if @loanStatus='IL'
if(15-100-80+12)>0
set @aa=15-100
else
set @aa=0
select @aa

推荐阅读