divide by zero error in sql

Solutions on MaxInterview for divide by zero error in sql by the best coders in the world

showing results for - "divide by zero error in sql"
Finn
12 Jul 2019
1#Dividing a/b
2
3SELECT a / NULLIF(b, 0) 
4FROM t 
5
Henry
26 Jan 2018
1SELECT club_id, 
2		males, 
3        females, 
4        males/NULLIF(females, 0) AS ratio
5  FROM school_clubs;
6
Fares
15 Jul 2018
1#Replace the result of divide by zero with 0
2
3SELECT COALESCE(dividend / NULLIF(divisor,0), 0) 
4FROM sometable
5