我正在尝试在数据库中创建一个检入/检出表。我想根据签入和签出输出员工的总工作时间,但是输出的是我当前的程序不是我想要的,而是得到了下面的区别
这是我的代码,请检查错误在哪里。
BEGIN
select att.PkID ,emp.username EmployeeName, IFNULL( att.CheckInTime,'--') CheckInTime,IFNULL( att.CheckOutTime,'--')CheckOutTime ,
HOUR(TIMEDIFF(cast(att.CheckOutTime AS datetime),cast(att.CheckInTime AS datetime))) WorkingHours
from attendance att
right outer join users emp
on emp.id=att.FKEmployeeId
where emp.username <> "Admin"
and date(att.CheckInTime) between date(startDate) and date(endDate)
and emp.Id=case when attendanceDateTime = 0 then emp.id else attendanceDateTime end ;
END