This is the error I'm receiving below:
Divide by zero error encountered.
Warning: Null value is eliminated by an aggregate or other SET operation.
Having looked around at solutions it looks like I need to use NULLIF or ISNULL, I'm just unsure as to how to include it within the line below.
select
min(round(OnCallTime*100/TotalTime,1)) as total
I'm using SQL Management Studio 2012
Use NULLIF in denominator like below:
select
min(round((OnCallTime*100/NULLIF(TotalTime,0)),1)) as total
So, whenever TotalTime is zero, it'll be replaced by NULL and you will not get the error of Division by Zero.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With