Advertisement
Guest User

Untitled

a guest
Jul 7th, 2017
351
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. select
  2.   sum(
  3.     abs(i1.time1 - i1.time2)
  4.     - (if (i1.time2 < i2.time1, 0,
  5.         (if (i1.time1 < i2.time1 AND i1.time2 > i2.time2, abs(i2.time1 - i2.time2),
  6.                 if (i1.time1 < i2.time1 AND i1.time2 < i2.time2, abs(i1.time2 - i2.time1), 0))
  7.                 )
  8.       ))
  9.   )
  10.  
  11.   from mytable i1 join mytable i2 limit 1000;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement