Alternative explanation (just in case, this is better for someone):
NULLs affect + , but do not affect SUM() : where NULL + -ed, it evaluates to NULL, where it is SUMmed, it is ignored. (But SUM() can return NULL if no argument was a value.)
So in your sample data (last) there is only one row that produces a non-NULL result for + , and this result is 9 , which also returns SUM() .
source share