select DT.depart,(select count(*) from PN where PN.departid=DT.depart),SY.salary
from depart as DT,salary as SY
where DT.departid=PN.departid and PN.departid=SY.departid
order by DT.depart
用departid作为索引,这样就简单查询了
select DT.depart,PN.person,SY.salary
from depart as DT,person as PN,salary as SY
where DT.departid=PN.departid and PN.departid=SY.departid
order by DT.depart