select 1+null;
+------+
|1+null|
+------+
|NULL |
+------+
select sum(1) as result;
+------+
|result|
+------+
|1 |
+------+
select sum(1+null) as result;
+------+
|result|
+------+
|NULL |
+------+
select sum(1+coalesce(null,0)) as result;
+------+
|result|
+------+
|1 |
+------+
总结
- 处理sum时注意对null的处理