SQL Server Check for IsNull and for Zero

前端 未结 4 1825
离开以前
离开以前 2021-02-07 18:59

I have the following:

set @SomeVariable = @AnotherVariable/isnull(@VariableEqualToZero,1) - 1 

If @VariableEqualToZero is null it substitutes t

4条回答
  •  情歌与酒
    2021-02-07 19:29

    set @SomeVariable = @AnotherVariable /
    (case when isnull(@VariableEqualToZero, 0) = 0 then 1 else
    @VariableEqualToZero end) - 1
    

提交回复
热议问题