我有以下几点:
set @SomeVariable = @AnotherVariable/isnull(@VariableEqualToZero,1) - 1
如果@VariableEqualToZero为空,则替换为1.如果@VariableEqualToZero = 0,则需要替换为1.我该怎么做?
解决方法
SET @SomeVariable = @AnotherVariable / COALESCE( CASE WHEN @VariableEqualToZero = 0 THEN 1 ELSE @VariableEqualToZero END,1) - 1