--group by与case when配合使用:
select
A,
count(case when not B is null then A end) as Cnt
from TBL 
group by A

--执行select A,case when not B is null then A end from TBL order by A会发现
--1、符合case when 条件的数据会原样返回,不符合条件的是null


--2、而count函数,不会计算B = null的行。
--3、所以,以上只会计算符合case when条件的count

相关文章:

  • 2021-12-04
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2023-01-04
  • 2021-05-09
  • 2022-01-29
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-10-21
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-09
相关资源
相似解决方案