使用COALESCE函数 当第一个值为null时则使用第二个值

select 
COALESCE(sum(number), 0) total
from work_order

统计work_order的number字段,当无数据时则返回0