select d.* ,t.title ,count(title) as count from departments as d inner join dept_emp on d.dept_no = dept_emp.dept_no inner join titles as t on t.emp_no = dept_emp.emp_no group by d.dept_no,t.title
1.先连表查询汇总所用需用数据
2.通过dept_no和title同时分组
select d.* ,t.title ,count(title) as count from departments as d inner join dept_emp on d.dept_no = dept_emp.dept_no inner join titles as t on t.emp_no = dept_emp.emp_no group by d.dept_no,t.title
1.先连表查询汇总所用需用数据
2.通过dept_no和title同时分组