I have the following statement which is still returning divide by zero error even when using the coalesce expression.
COALESCE(CAST(sum(case when W0.i13 = 1 then 1 else 0 end)AS FLOAT) / CAST(sum(case when W0.i13 <> 0 then 1 else 0 end) AS FLOAT),0)
Msg 8134, Level 16, State 1, Line 1 Divide by zero error encountered.
I also tried the following and still get the error
COALESCE(CAST(sum(case when W0.i13 = 1 then 1 else 0 end)AS FLOAT),0) / COALESCE(CAST(sum(case when W0.i13 <> 0 then 1 else 0 end) AS FLOAT),0)
0as setting 0 is your default value inCOALESCE- Mahesh