我想要做的是从“punch_in_utc_time”和“punch_out_utc_time”的时差中扣除一小时,如果它超过5小时,如果我们每天有超过5小时的时差的多个记录,那么这应该只进行一次。如果“has_overnight_shift”为“1”,也需要跳过扣除。完成所有这些操作之后,我还需要“group by”“employee_id”。我可以从所有记录中扣除一小时,但不仅每天一次。你能救我吗?
如果您需要csv数据:
“1”,“54”,“2017-10-05 12:30:00”,NULL,“5.5”,“2017-10-05 18:00:00”,“2017-10-05 18 :29:00“,NULL,”5.5“,”2017-10-05 23:59:00“,”PUNCHED OUT“,”0“ “2”,“54”,“2017-10-05 18:30:00”,NULL,“5.5”,“2017-10-06 00:00:00”,“2017-10-06 00:30: 00“,NULL,”5.5“,”2017-10-06 06:00:00“,”PUNCHED OUT“,”1“ “3”,“54”,“2017-10-06 02:30:00”,NULL,“5.5”,“2017-10-06 08:00:00”,“2017-10-06 06:30: 00“,NULL,”5.5“,”2017-10-06 12:00:00“,”PUNCHED OUT“,”0“ “4”,“54”,“2017-10-07 00:30:00”,NULL,“5.5”,“2017-10-07 06:00:00”,“2017-10-07 06:30: 00“,NULL,”5.5“,”2017-10-07 12:00:00“,”PUNCHED OUT“,”0“ “5”,“54”,“2017-10-07 07:30:00”,NULL,“5.5”,“2017-10-07 13:00:00”,“2017-10-07 13:30: 00“,NULL,”5.5“,”2017-10-07 19:00:00“,”PUNCHED OUT“,”0“ “6”,“54”,“2017-10-08 02:30:00”,NULL,“5.5”,“2017-10-08 08:00:00”,“2017-10-08 04:30: 00“,NULL,”5.5“,”2017-10-08 10:00:00“,”PUNCHED OUT“,”0“ “7”,“54”,“2017-10-08 05:30:00”,NULL,“5.5”,“2017-10-08 11:00:00”,“2017-10-08 06:30: 00“,NULL,”5.5“,”2017-10-08 12:00:00“,”PUNCHED OUT“,”0“ “8”,“54”,“2017-10-08 07:30:00”,NULL,“5.5”,“2017-10-08 13:00:00”,“2017-10-08 09:30: 00“,NULL,”5.5“,”2017-10-08 15:00:00“,”PUNCHED OUT“,”0“ “9”,“54”,“2017-10-15 12:30:00”,NULL,“5.5”,“2017-10-15 18:00:00”,“2017-10-15 18:29: 00“,NULL,”5.5“,”2017-10-15 23:59:00“,”PUNCHED OUT“,”0“ “10”,“54”,“2017-10-15 18:30:00”,NULL,“5.5”,“2017-10-16 00:00:00”,“2017-10-16 00:30: 00“,NULL,”5.5“,”2017-10-16 06:00:00“,”PUNCHED OUT“,”1“ “11”,“54”,“2017-10-16 02:30:00”,NULL,“5.5”,“2017-10-16 08:00:00”,“2017-10-16 06:30: 00“,NULL,”5.5“,”2017-10-16 12:00:00“,”PUNCHED OUT“,”0“ “12”,“54”,“2017-10-17 00:30:00”,NULL,“5.5”,“2017-10-17 06:00:00”,“2017-10-17 06:30: 00“,NULL,”5.5“,”2017-10-17 12:00:00“,”PUNCHED OUT“,”0“ “13”,“54”,“2017-10-17 07:30:00”,NULL,“5.5”,“2017-10-17 13:00:00”,“2017-10-17 13:30: 00“,NULL,”5.5“,”2017-10-17 19:00:00“,”PUNCHED OUT“,”0“ “14”,“54”,“2017-10-18 02:30:00”,NULL,“5.5”,“2017-10-18 08:00:00”,“2017-10-18 04:30: 00“,NULL,”5.5“,”2017-10-18 10:00:00“,”PUNCHED OUT“,”0“ “15”,“54”,“2017-10-18 05:30:00”,NULL,“5.5”,“2017-10-18 11:00:00”,“2017-10-18 06:30: 00“,NULL,”5.5“,”2017-10-18 12:00:00“,”PUNCHED OUT“,”0“ “16”,“54”,“2017-10-18 07:30:00”,NULL,“5.5”,“2017-10-18 13:00:00”,“2017-10-18 09:30: 00“,NULL,”5.5“,”2017-10-18 15:00:00“,”PUNCHED OUT“,”0“ “17”,“54”,“2017-10-19 12:30:00”,NULL,“5.5”,“2017-10-19 18:00:00”,“2017-10-19 18:29: 00“,NULL,”5.5“,”2017-10-19 23:59:00“,”PUNCHED OUT“,”0“ “18”,“54”,“2017-10-19 18:30:00”,NULL,“5.5”,“2017-10-20 00:00:00”,“2017-10-20 00:30: 00“,NULL,”5.5“,”2017-10-20 06:00:00“,”PUNCHED OUT“,”1“ “19”,“54”,“2017-10-20 02:30:00”,NULL,“5.5”,“2017-10-20 08:00:00”,“2017-10-20 06:30: 00“,NULL,”5.5“,”2017-10-20 12:00:00“,”PUNCHED OUT“,”0“ “20”,“54”,“2017-10-21 00:30:00”,NULL,“5.5”,“2017-10-21 06:00:00”,“2017-10-21 06:30: 00“,NULL,”5.5“,”2017-10-21 12:00:00“,”PUNCHED OUT“,”0“ “21”,“54”,“2017-10-21 07:30:00”,NULL,“5.5”,“2017-10-21 13:00:00”,“2017-10-21 13:30: 00“,NULL,”5.5“,”2017-10-21 19:00:00“,”PUNCHED OUT“,”0“ “22”,“54”,“2017-10-22 02:30:00”,NULL,“5.5”,“2017-10-22 08:00:00”,“2017-10-22 04:30: 00“,NULL,”5.5“,”2017-10-22 10:00:00“,”PUNCHED OUT“,”0“ “23”,“54”,“2017-10-22 05:30:00”,NULL,“5.5”,“2017-10-22 11:00:00”,“2017-10-22 06:30: 00“,NULL,”5.5“,”2017-10-22 12:00:00“,”PUNCHED OUT“,”0“ “24”,“54”,“2017-10-22 07:30:00”,NULL,“5.5”,“2017-10-22 13:00:00”,“2017-10-22 09:30: 00“,NULL,”5.5“,”2017-10-22 15:00:00“,”PUNCHED OUT“,”0“
先谢谢。
答案 0 :(得分:0)
好的解决了我的问题。我做的是在进行这种操作后,我动态创建了一个临时表并填充这些新数据,然后按条件应用该组。 谢谢你的时间伙伴..