Good day everyone, please if you can help me, I require the following:
-I have 4 fields: start_time, end_time (time) start_date, end_date (date)
There is a table that contains these records. It is required to calculate the time between the first and last record. Then find the average of these records in a month.
I made this query, but it is required to calculate the time between hours and dates.
select o.codigo as incidente, op.hora_inicio, op.hora_fin,
TIMESTAMPDIFF(MINUTE , op.hora_inicio, op.hora_fin ) AS Tiempo,
op.fecha_inicio, op.fecha_fin, o.fecha, i.valor as codigo_incidente
from operacion o
inner join incidente i
on i.codigo=o.incidente_codigo
inner join operacion_detalle op
on op.codigo_operacion=o.codigo
where o.codigo='1042'
order by op.hora_inicio ASC;