简单做的话,可以在除数:(count(distinct case when b.status=1 then b.taskid end)+count(case when b.taskid=0 and b.status=0 then b.taskid end)) 的外层加一个decode
decode((count(distinct case when b.status=1 then b.taskid end)+count(case when b.taskid=0 and b.status=0 then b.taskid end)),0,1,(count(distinct case when b.status=1 then b.taskid end)+count(case when b.taskid=0 and b.status=0 then b.taskid end)))
case when xxx=0 then 1 else xxx end 这样么?
用 case when then else 试试 应该可以的