I want to calculate the total number of employees logged in the system at a particular time and also the total work hour of each.
We have the login system which stores the data in the following data structure:
1.EmpId
2.Status
3.Created
The above data is stored in the following table:
EmpId Status Created
1 In 2019-10-23 12:00:00
1 Out 2019-10-23 12:45:45
2 In 2019-10-23 14:25:40
1 In 2019-10-23 18:45:45
2 Out 2019-10-23 20:50:40
2 In 2019-10-24 1:27:24
3 In 2019-10-24 2:45:45
The In is followed by Out and vice versa. And the employees work duration is spread across days, I mean the in and out could be across the days.
I need to implement the following:
How to calculate the number of employees logged in at a particular time say, "2019-10-23 14:12:45".
How to calculate the total work hours of all the employees since start?