如何根据InOutMode计算TotalWorking小时数? [英] How Can I calculate the TotalWorking hours according to the InOutMode ?

查看:106
本文介绍了如何根据InOutMode计算TotalWorking小时数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试按员工计算总工时:

我的表格Log_Attendance就像这样



I'm Trying to calculate the total worked hours by employee:
My table "Log_Attendance" like this

EnrollNumber       InOutMode       DateAttendance       TimesInOut
27                   0              07-09-2015           07-09-2015 08:00:00
27                   2              07-09-2015           07-09-2015 10:00:00
27                   3              07-09-2015           07-09-2015 11:00:00
27                   1              07-09-2015           07-09-2015 12:00:00
27                   0              07-09-2015           07-09-2015 13:00:00
27                   1              07-09-2015           07-09-2015 17:00:00







InOutMode-->  0:CheckIn     1: CheckOut         2:BreakIn        3:BreakOut



我只需要计算工作时间!

例如:


I need to calculate only the worked hours!
example:

EnrollNumber       TotalWorkedHours
27                       7    (=(10-8)+(12-11)+(17-13))



任何解决方案请


Any Solution please

推荐答案

如果我理解正确,你需要为in和for取一行来计算差异吗?



如果是这样,或许类似于:

If I understand correctly, you need to fetch a row for in and for out and to calculate the difference?

If so, perhaps something like:
SELECT DATEDIFF(hour, out. TimesInOut, in.TimesInOut)
FROM Log_Attendance in,
     Log_Attendance out
WHERE in.enrollnumber = out.enrollnumber
AND   in.inoutmode = 0
AND   out.inoutmode = 1
AND   in.DateAttendance = out.DateAttendance
...





当然这不是整个逻辑,但它会让你开始......



Of course that's not the whole logic but it'll jopefully get you started...


这篇关于如何根据InOutMode计算TotalWorking小时数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆