0
I need to calculate the time difference between one record and another, see that on the same day I have several records and I have several people. I found nothing calculating between times in the same column.
SELECT t.nm_primeiro_nome nome,
ro.tm_check as horario
from tbl_funcionario t
left join tbl_registro ro
on t.nr_cracha = ro.nm_registro
left join tbl_ordem_diaria od
on od.pk_ordem = ro.fk_os
where od.pk_ordem is not null
order by 1,2 desc;
nome horario
Carlos 26/06/2019 14:09:04
Carlos 26/06/2019 11:42:44
Carlos 26/06/2019 11:10:26
Carlos 26/06/2019 11:04:25
Carlos 26/06/2019 10:58:50
Carlos 26/06/2019 09:43:24
Carlos 26/06/2019 09:39:06
Carlos 26/06/2019 07:50:09
Carlos 26/06/2019 07:41:41
Carlos 26/06/2019 06:13:09
Carlos 19/06/2019 13:59:40
Carlos 19/06/2019 13:12:38
Carlos 19/06/2019 13:07:41
Carlos 19/06/2019 11:42:37
Carlos 19/06/2019 11:11:36
Carlos 19/06/2019 11:10:57
Carlos 19/06/2019 11:07:57
Carlos 19/06/2019 10:03:36
Carlos 19/06/2019 09:57:59
Carlos 19/06/2019 07:35:50
Carlos 19/06/2019 07:26:45
Carlos 19/06/2019 06:17:43
Carlos 17/06/2019 13:18:48
Carlos 17/06/2019 13:08:10
Carlos 17/06/2019 11:42:36
Carlos 17/06/2019 11:10:48
Carlos 17/06/2019 09:24:13
Carlos 17/06/2019 09:09:27
Carlos 13/06/2019 14:00:19
Carlos 13/06/2019 11:10:39
Carlos 13/06/2019 10:39:46
Carlos 13/06/2019 10:13:55
Carlos 13/06/2019 09:37:38
Carlos 13/06/2019 09:30:26
Carlos 13/06/2019 08:22:47
Carlos 13/06/2019 08:14:12
Carlos 13/06/2019 08:06:24
Carlos 11/06/2019 16:23:38
Carlos 11/06/2019 12:16:33
Carlos 11/06/2019 12:11:57
Carlos 11/06/2019 11:44:56
Carlos 11/06/2019 09:53:05
In that link he makes the whole comparison I need the difference between dates
you’ve researched the function LAG and LEAD ? The LEAD() and LAG() function in Mysql is used to get the previous and successive value of any row within its partition. These functions are referred to as non-aggregated window functions.
– Edvaldo Lucena
You must use "Running Total" to make this account. See this link! (in English) and see if it helps you.
– Thiago Araújo