select a.dname,
sum(case when a.deptno=b.deptno then 1 else 0 end) 人数
from dept a left join emp b on a.deptno=b.deptno
group by a.dname
--try this sql
select A.DEPTNO, a.dname, count(B.EMPNO) "COUNT"
from dept a
left join emp b
on a.deptno = b.deptno
group by a.dname, A.DEPTNO
ORDER BY A.DEPTNO;