SELECT 
    department,
    CONCAT(ROUND(
        100 * SUM(TIMESTAMPDIFF(SECOND, first_clockin, last_clockin)/3600 > 9.5) / 
        COUNT(DISTINCT s.staff_id), 
        1
    ), '%') AS ratio
FROM staff_tb s
LEFT JOIN attendent_tb a USING(staff_id)
GROUP BY department
ORDER BY ratio DESC