All pastes #435971 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-04-12 08:46 UTC
rendered paste body
churn=# select reg,count(distinct case when no_of_mon=1 then cust_cod else null
end) as base,count(distinct case when no_of_mon=2 and status='churn' then cust_c
od else null end) as current,(100-((count(distinct case when no_of_mon=1 then cu
st_cod else null end)-count(distinct case when no_of_mon=2and status='churn' the
n cust_cod else null end))*100/count(distinct case when no_of_mon=1 then cust_co
d else null end))) as percentage FROM churn WHERE arpu_id IN('1000-2000')  AND c
_type='P' GROUP BY reg;

ERROR:  division by zero

now i want to set the count value to 1 if it is 0.