MySQL Forums
Forum List  »  General

Help dealing with employee working schedule
Posted by: Fabio Facchetti
Date: December 28, 2016 05:36PM

Hello, I work at an employment & paycheck-making company and we handle the badge timestamp data of about 400k employees, and we use that data to calculate their monthly pay.
The problem is that the badge machine creates one record for each time employees use their badge.

For example:

EmpID --- Date ---------- Time -- Type
430016 - 29/12/2016 - 09:01 - In
430016 - 29/12/2016 - 11:02 - Out
430016 - 29/12/2016 - 11:13 - In
430016 - 29/12/2016 - 13:02 - Out
430016 - 29/12/2016 - 13:56 - In
430016 - 29/12/2016 - 15:38 - Out
430016 - 29/12/2016 - 15:47 - In
430016 - 29/12/2016 - 17:02 - Out

In this case Employee #430016 checked in to his workplace with his badge at 09:01;
He had a coffee break 11:02 - 11:13
Then he had lunch break between 13:02 and 13:56 PM
Then had another coffee break between 15:38 - 15:47
He finally finished his work day at 17:02.
It's a basic 9-5 job with 3 breaks and yet I have it spread in 8 records.

As you can imagine, with this system 400k employees generate up to 3.2mil records in a single day.
I'm trying to make a mysql query to filter this table so that each employee has a single record for each day with all his badge stamps.

For example:

EmpID ----- Date --------- In1 ---- Out1 ---- In2 ---- Out2 --- In3 --- Out3 -- In4 --- Out4
0430016 - 29/12/2016 - 09:01 - 11:02 - 11:13 - 13:02 - 13:56 - 15:38 - 15:47 - 17:02

This way I could use this query for each company and have only 400k records / day to deal with.

I tried several things but I'm not close to a solution yet, could you help?

Thanks!

Options: ReplyQuote


Subject
Written By
Posted
Help dealing with employee working schedule
December 28, 2016 05:36PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.