When MySQL SUM() function got a column, having no values, as an argument then it will return NULL, rather than 0, as output. The column can be of any data type. Following the example, using a table named ‘social’ having only one column named ‘id’ with no values, will illustrate it
Example
mysql> Describe Social; +-------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+-------------+------+-----+---------+-------+ | Id | int(11) | YES | | NULL | | | Name | varchar(20) | YES | | NULL | | +-------+-------------+------+-----+---------+-------+ 2 rows in set (0.00 sec) mysql> Select * from Social; Empty set (0.00 sec) mysql> Select SUM(id) from Social; +---------+ | SUM(id) | +---------+ | NULL | +---------+ 1 row in set (0.00 sec) mysql> Select SUM(Name) from Social; +-----------+ | SUM(Name) | +-----------+ | NULL | +-----------+ 1 row in set (0.00 sec)