SELECT post ,round(avg(TIMESTAMPDIFF(second, first_clockin,last_clockin)/3600),3) as work_hours FROM staff_tb a JOIN attendent_tb b ON a.staff_id = b.staff_id WHERE first_clockin IS NOT NULL AND last_clockin IS NOT NULL GROUP BY post ORDER BY work_hours DESC