Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Get overlaped time range with conditions
- key | start | end | employee(fk)
- 1 6:00 8:00 A
- 2 9:00 11:00 B
- 3 7:00 9:00 B
- 4 7:00 11:00 C
- given {A,B} returns 2 columns 7:00 | 8:00 time range which overlaped by A and B
- given {B,C} returns 2 columns 9:00 | 11:00 time range which overlaped by B and C
- SELECT T1.employee, T2.employee, T1.start, T2.end
- FROM Table T1, Table T2
- WHERE T1.key!=T2.key AND T1.employee!=T2.employee
- AND T1.start <= T2.end AND T1.start >= T2.start
Add Comment
Please, Sign In to add comment