SELECT DISTINCT attendmatch.employeeno, attendmatch.overtimedate, employee.Workhours, attendmatch.timediff, abs((attendmatch.timediff)-(employee.Workhours)and <>(employee.category='Restday') AS Diffhours, overtime.othours,overtime.categoryday,overtime.department
FROM attendmatch, employee, overtime
WHERE attendmatch.employeeno=employee.employeeno and attendmatch.employeeno=overtime.employeeno and attendmatch.overtimedate=overtime.overtimedate
GROUP BY attendmatch.employeeno, employee.employeeno, attendmatch.overtimedate, employee.Workhours, attendmatch.timediff, overtime.othours, overtime.categoryday,
overtime.department