select d.dept_no,d.dept_name,t.title,count(*) as count from dept_emp de inner join departments d on de.dept_no = d.dept_no inner join titles t on de.emp_no = t.emp_no where de.to_date = '9999-01-01' group by t.title,d.dept_name order by d.dept_no asc,t.title asc;