if 和case

时间:2021-08-26 08:10:14

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