SELECT A.post,AVG(TIMESTAMPDIFF(MINUTE,B.first_clockin,B.last_clockin)/60) AS work_hours FROM staff_tb A JOIN attendent_tb B ON A.staff_id=B.staff_id GROUP BY A.post ORDER BY AVG(TIMESTAMPDIFF(MINUTE,B.first_clockin,B.last_clockin)/60) DESC