Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT d.id, d.dni, (select t.fecha from datos t where t.Evento=1 and t.Valor=0 and t.dni=d.dni and t.id<d.id order by t.id desc Limit 1) as Fecha_Salida,
- d.fecha as Fecha_Entrada, TIMESTAMPDIFF(MINUTE, (select t.fecha from datos t where t.Evento=1 and t.Valor=0 and t.dni=d.dni and t.id<d.id order by t.id desc Limit 1), d.fecha) as MINUTOS
- FROM datos d
- where d.Evento=1 and d.valor=1 and month(d.fecha)=month(curdate())
- order by d.id desc;
Add Comment
Please, Sign In to add comment