I appeal to you for support and suggestions. I have the following table in SQL:
It is the record of entries and exits of employees that keeps a clock, as you will see it is not possible to differentiate inputs from outputs since everything is inserted as a column. I have no problem with getting the time of entry and exit of those employees who are NOT assigned a night shift, since I am using a select min and max in the hour field and grouping by date and employee ID. Where I have a problem is with those employees who have assigned a night shift: / since I do not know how to select your time of entry and exit as it registers entry one day (15-12-2017 22:00) and leaves the next day (16- 12-2017 6:00), it is even possible that by mistake check twice either in and out, in this case I occupy all the way to display min and max time. Any suggestion of what you can do about it? What I occupy is to obtain an exit like this:
The query that I am currently using is:
SELECT MIN(Hora) as HoraEntrada,MAX(Hora)AS HoraSalida,Fecha,IDEmpleado, IdTurno, TurnoNocturno FROM RegistroEmpleados GROUP BY IDEmpleado,Fecha,IdTurno,TurnoNocturno
I would greatly appreciate your help.
Greetings!