Since you're trying to determine if any of the requirements expired, you should compare the minimal expiry date to today's date. There's no need to use datediff
- a simple >
operator packed in a case
statement would do:
SELECT id_emp,
employee,
COUNT(*) AS requirements_got,
CASE WHEN CURDATE() > MIN(expiration) THEN 'yes' ELSE 'no' END AS any_req_expire
FROM tb_detail
JOIN tb_employee ON tb_detail.id_emp = tb_employee.id_emp
GROUP BY id_emp, employee