Advertisement
Guest User

Untitled

a guest
Feb 24th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. Name TimeIn TimeOut
  2.  
  3. Bob 2012-07-17 07:00:00.000 2012-07-17 16:00:00.000
  4. Sam 2012-07-17 10:00:00.000 2012-07-17 20:00:00.000
  5. Beatly 2012-07-17 14:00:00.000 2012-07-17 23:00:00.000
  6. Mac 2012-07-17 21:00:00.000 2012-07-18 07:00:00.000
  7.  
  8. Name TimeIn TimeOut
  9. Fred 2012-07-17 15:59:00.000 2012-07-18 00:19:00.000
  10.  
  11. DirName HelperStart HelperEnd
  12. Bob 2012-07-17 15:59:00.000 2012-07-17 16:00:00.000
  13. Sam 2012-07-17 15:59:00.000 2012-07-17 16:00:00.000
  14. Beatly 2012-07-17 15:59:00.000 2012-07-17 16:00:00.000
  15. Sam 2012-07-17 16:01:00.000 2012-07-17 20:00:00.000
  16. Beatly 2012-07-17 16:01:00.000 2012-07-17 20:00:00.000
  17. Beatly 2012-07-17 20:01:00.000 2012-07-17 21:00:00.000
  18. Beatly 2012-07-17 21:01:00.000 2012-07-17 23:00:00.000
  19. Mac 2012-07-17 21:01:00.000 2012-07-17 23:00:00.000
  20. Mac 2012-07-17 23:01:00.000 2012-07-18 00:19:00.000
  21.  
  22. select d.name as DirectorName, h.name as HelperName,
  23. (case when d.timeIn > h.timeIn then d.timeIn else h.timeIn end) as HelperStart,
  24. (case when d.timeOut > h.timeOut then h.timeOut else d.timeOut end) as HelperEnd
  25. from director d join
  26. helper h
  27. on d.timeIn < h.timeOut and
  28. d.timeOut >= h.timeIn
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement