简书链接:sqlservercount计算可能出现惯性思维计算错误的问题避坑
文章字数:76,阅读全文大约需要1分钟
有一个a表left join 关联b表查询 where为b.name is null 那么查到的都是b表没有的记录

select count(b.name) from a a left join b b on a.name =b.name where b.name is null
在ssms会提示一个警告null为被抹除,假设实际上有5条记录但是得到的还是0 ,所以改为 count(*)或者count(a.name)就能正常计算了