2
I have a system where user logs in and drops the tool several times a day during their work hours. I need to calculate the amount of time it was logged in:
The columns LOGOUT
and LOGIN
are in seconds.
SELECT DATA,USUARIO,SUM(PERIODO_LOGADO) AS TOTAL_LOGADO
FROM (
SELECT DATA,USUARIO,LOGOUT-LOGIN AS PERIODO_LOGADO
FROM HISTORICO_LOGIN
GROUP BY DATA,USUARIO,LOGOUT-LOGIN
) SUB
GROUP BY DATA,USUARIO
This consultation works, but there is the case of employees who work at dawn, and end up having time counted on separate days.
How to join the two times or calculate the total hours worked dynamically?
I didn’t understand the LOGOUT and LOGIN columns, are they date type? They mark the Login date and the Logout date, that’s it?
– cantoni