select t1.staff_id, t1.staff_name, concat(round(sum(dock_salary) / sum(normal_salary)*100,1),"%") as dock_ratio from ( select staff_id, staff_name from staff_tb where department = "dep1" ) t1 left join salary_tb using (staff_id) group by t1.staff_id, t1.staff_name order by dock_ratio desc