Guest User

Untitled

a guest
Oct 23rd, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. 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,
  2. 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
  3. FROM datos d
  4. where d.Evento=1 and d.valor=1 and month(d.fecha)=month(curdate())
  5. order by d.id desc;
Add Comment
Please, Sign In to add comment