Simple way to prevent a Divide By Zero error in SQL

前端 未结 5 1232
陌清茗
陌清茗 2021-02-05 17:15

I have a SQL query which used to cause a

Divide By Zero exception

I\'ve wrapped it in a CASE statement to stop this fr

5条回答
  •  鱼传尺愫
    2021-02-05 17:38

    A nicer way of doing this is to use NULLIF like this:

    Percentage =  100 * ClubTotal / NULLIF(AttTotal, 0)
    

提交回复
热议问题