17,090
社区成员
发帖
与我相关
我的任务
分享
-- 如果b表in字段不会重复 如下 dept中deptno不会重复
select sum(case when b.deptno is null then 0 else 1 end),
sum(case when b.deptno is null then 1 else 0 end)
from EMP a
left join dept b on a.deptno = b.deptno;
-- 如果b表in字段会重复 如下 dept中同一个deptno可能存在多条数据
select sum(case when b.deptno is null then 0 else 1 end),
sum(case when b.deptno is null then 1 else 0 end)
from EMP a
left join (select deptno from dept group by deptno) b on a.deptno = b.deptno