How MySQL SUM() function evaluates if it got the column, having character data type, as its argument?

MySQLMySQLi Database

MySQL SUM() function will return 0, rather than NULL, along with a warning on getting the character type column as its argument. Following example using data from table named ‘Social’ will illustrate it −

Example

mysql> Select * from Social;

+------+-------+
| Id   | Name  |
+------+-------+
| 100  | Rahul |
+------+-------+

1 row in set (0.00 sec)

mysql> Select SUM(Name) From Social;

+-----------+
| SUM(Name) |
+-----------+
| 0         |
+-----------+

1 row in set, 1 warning (0.00 sec)
raja
Published on 20-Feb-2018 09:18:29
Advertisements