Hello,
Say we have a table like below:
Please note the start and end time and if they start or end at the same time then they need to be combined. Thanks.
EMP ID Schedule 1 start time Schedule 1 End Time Schedule 2 start time Schedule 2 End Time
1 2020-03-01 7:00am 2020-03-01 10:00am 2020-03-01 10:00am 2020-03-01 08:00pm
1 2020-03-04 6:00am 2020-03-04 4:00pm 2020-03-04 5:00pm 2020-03-04 10:00pm
1 2020-03-04 10:00pm 2020-03-05 06:00am 2020-03-07 06:00am 2020-03-07 10:00am
How do we combine these schedules without a cursor/loop so that it becomes
EMP ID Schedule 1 start time Schedule 1 End Time Schedule 2 start time Schedule 2 End Time
1 2020-03-01 7:00am 2020-03-01 08:00pm 2020-03-04 6:00am 2020-03-04 4:00pm
1 2020-03-04 5:00pm 2020-03-05 06:00am 2020-03-07 06:00am 2020-03-07 10:00am