create table testTable(
 id int,
 val int
 );


  insert into testTable  values(1, null);
  insert into testTable  values(null, 1);
  insert into testTable  values(1, 1);
 


select count(id), count(val), count(*), count(1) from testTable;


可见 count 函数   对字段值count操作时  值为null的没有计算。



select  sum(val),sum(id) from testTable;




 聚合或其他 SET 操作消除了 Null 值。



本文转载:CSDN博客