关于sql中case判断的使用
create function SXTEST(@type int,@first float,@second float)returns floatasbegindeclare @result floatif(@type=1)--"+"begin set @result=@first+@secondendif(@type=2)--"-"begin set @result=@first-@secondendreturn @resultend
create function SXTEST(@type int,@first float,@second float)returns floatasbegindeclare @result floatselect @result = case @type when 1 then @first+@second when 2 then @first - @second endend
[解决办法]
create function SXTEST(@type int,@first float,@second float)returns floatasbegindeclare @result floatSELECT @result= CASE WHEN @type=1 THEN @first+@second WHEN @type=0 THEN @first-@second ELSE 0 ENDreturn @resultend