用where将departments,dept_emp,titles连接起来,然后用group by根据dept_no,title分组,这时count就可以根据第二层group来计算每个title的数量,最后再根据dept_no,title排序
select d.dept_no, d.dept_name, t.title, count(t.title)
from departments as d, dept_emp as de, titles as t
where d.dept_no = de.dept_no and de.emp_no = t.emp_no
group by d.dept_no, t.title
order by d.dept_no, t.title