select t1.dept_no, t1.dept_name, COUNT(t3.salary) as sum from departments t1 JOIN dept_emp t2 on t1.dept_no=t2.dept_no join salaries t3 on t2.emp_no=t3.emp_no group by t1.dept_no order by t1.dept_no asc