Oracle数据库group by与case when配合使用

--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

原文地址:https://www.cnblogs.com/gongjin/p/7802515.html