select b.DEPTNO, b.DNAME, b.LOC,count(*) count from emp a,dept b
where a.DEPTNO=b.DEPTNO group by b.DEPTNO, b.DNAME, b.LOC
用手机写的,不能调试不好意思。 select emp.count(*),dept.deptno,dept.dname,dept.loc from dept,emp where emp.deptno=dept.deptno group by deptno deptno 大体的应该是这样,希望对您有帮助
select a.DEPTNO,DNAME,LOC,count(distinct ENAME) 人数
from dept a
left join emp b
on a.DEPTNO=b.DEPTNO
group by a.DNAME