Guest User

Untitled

a guest
Aug 17th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. Get overlaped time range with conditions
  2. key | start | end | employee(fk)
  3. 1 6:00 8:00 A
  4. 2 9:00 11:00 B
  5. 3 7:00 9:00 B
  6. 4 7:00 11:00 C
  7.  
  8. given {A,B} returns 2 columns 7:00 | 8:00 time range which overlaped by A and B
  9. given {B,C} returns 2 columns 9:00 | 11:00 time range which overlaped by B and C
  10.  
  11. SELECT T1.employee, T2.employee, T1.start, T2.end
  12. FROM Table T1, Table T2
  13. WHERE T1.key!=T2.key AND T1.employee!=T2.employee
  14. AND T1.start <= T2.end AND T1.start >= T2.start
Add Comment
Please, Sign In to add comment