在这种情况下,当存储函数获取 NULL 值时,它将返回 NULL 作为结果。从下面的例子可以看出,学生‘Mohit’的记录中有一个NULL值。现在,当我们对此数据应用存储的函数“avg_marks”时,它将返回 NULL 作为结果。
mysql> Select * from Student_marks;
+-------+------+---------+---------+---------+
| Name | Math | English | Science | History |
+-------+------+---------+---------+---------+
| Raman | 95 | 89 | 85 | 81 |
| Rahul | 90 | 87 | 86 | 81 |
| Mohit | 90 | NULL | 86 | 81 |
+-------+------+---------+---------+---------+
3 rows in set (0.00 sec)
mysql> SELECT Avg_marks('Mohit') AS 'MOHIT_marks';
+-------------+
| MOHIT_marks |
+-------------+
| NULL |
+-------------+
1 row in set (0.00 sec)