select count(*)
from
(
select 1 as c1
union all
select null as c1
) -- 2 , count(*) 包含null值
select count(c1)
from
(
select 1 as c1
union all
select null as c1
) -- 1 , count(c1) 不包含null值
select count(case when 1=1 then 1 else 0 end) ; -- 1
select count(case when 1<>1 then 1 else null end) -- 0
select count(0) -- 1
select count(null) -- 0
select
type,
count(case when status = 3 then id else null end) as cnt
from (
select
1 as id ,
2 as status,
1 as type
union ALL
select
3 as id ,
4 as status,
1 as type
union ALL
select
2 as id ,
3 as status,
2 as type
union ALL
select
4 as id ,
3 as status,
2 as type
) t1
group by type
order by type ;