如何修复SQL中的“除以零”错误?

时间:2017-05-03 14:39:54

标签: sql postgresql

我的查询是:

Select sum (node.weight * ans.cn_age) / sum (node.weight) as sum_weight , poll.pollName as poll , poll.endDate as date 
From  report.cm_job_satisfaction ans 
Join poll_management.POLLES poll on ans.cn_pollid = poll.id 
Join poll_management.POSITIONS node on ans.cn_positionid = node.id  
Group by poll , date 
Order by date

但我有错误:

ERROR:  division by zero
********** Error **********

ERROR: division by zero
SQL state: 22012

我知道因为某些node.weight是0然而如何解决这个问题?

0 个答案:

没有答案
相关问题