关于MySql函数avg的使用特性-null值不计入统计(但是0参与计算)

总结

  mysql中聚合函数都忽略null值

官方描述

  In MySQL, All Group functions ignore NULL values. For example: the average price is calculated based on the rows in the table where a valid value is stored (the total price divided by the number of books with a price).

  In MySQL You can use the IFNULL function to force group functions to include NULL values, in the following example the average is calculated based on all rows in the table, regardless of whether null values are stored in the price column (the total price divided by the total number of rows in the table):

posted @ 2022-10-11 15:11  风不会停息7  阅读(7)  评论(0编辑  收藏  举报