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



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)
Updated on: 2020-02-07T05:43:43+05:30

167 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements