sql函数count()中可以直接加条件
例:select
count(status = ‘1’ or null) as “ok”,
count(status = ‘2’ or null) as “warning”,
count(status in (‘3’, ‘4’) or null) as “ng”,
count(id) as “sum”
from
test
运行结果:2 4 2 8
由此可见,count()中追加条件是好用的
注意:条件后需追加”OR NULL”,没有的话count()中的条件失效。
至于为什么要加上这个,链接如下
https://blog.csdn.net/qq_32719287/article/details/79513164: