In a queries like
SELECT dividend/divisor AS data FROM table
The divisor can have a zero value, then SQL server returns an error “Division by zero encountered”.
To avoid this we have to always check the divisor for zero value
CASE WHEN divisor=0 THEN 0 ELSE dividend/divisor END AS data FROM table