Simple way to prevent a Divide By Zero error in SQL

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

[code type=sql]Percentage = 100 * ClubTotal / NULLIF(AttTotal, 0)

https://docs.microsoft.com/en-us/sql/t-sql/language-elements/nullif-transact-sql

Share and Enjoy !

0Shares
0 0 0