Loading problem...
A workforce analytics team wants to measure scheduling pressure from employee shift timelines.
Table: EmployeeShifts
The pair (employee_id, start_time) is unique.
For each employee_id, compute two metrics:
Same-date rule:
Interval rule:
Output requirements:
Supported submission environments:
EmployeeShifts:
| employee_id | start_time | end_time |
|-------------|----------------------|----------------------|
| 1 | 2024-10-01 09:00:00 | 2024-10-01 17:00:00 |
| 1 | 2024-10-01 15:00:00 | 2024-10-01 23:00:00 |
| 1 | 2024-10-01 16:00:00 | 2024-10-02 00:00:00 |
| 2 | 2024-10-01 09:00:00 | 2024-10-01 17:00:00 |
| 2 | 2024-10-01 11:00:00 | 2024-10-01 19:00:00 |
| 3 | 2024-10-01 09:00:00 | 2024-10-01 17:00:00 |[
{"employee_id":1,"max_overlapping_shifts":3,"total_overlap_duration":600},
{"employee_id":2,"max_overlapping_shifts":2,"total_overlap_duration":360},
{"employee_id":3,"max_overlapping_shifts":1,"total_overlap_duration":0}
]Employee 1 peaks at 3 simultaneous shifts and accumulates 600 pairwise-overlap minutes. Employee 2 has a single 6-hour overlap window. Employee 3 has no overlap.
EmployeeShifts:
| employee_id | start_time | end_time |
|-------------|----------------------|----------------------|
| 10 | 2024-01-05 22:00:00 | 2024-01-06 02:00:00 |
| 10 | 2024-01-06 00:30:00 | 2024-01-06 03:30:00 |
| 10 | 2024-01-06 08:00:00 | 2024-01-06 11:00:00 |
| 10 | 2024-01-06 10:00:00 | 2024-01-06 12:00:00 |
| 11 | 2024-01-06 07:00:00 | 2024-01-06 08:00:00 |
| 11 | 2024-01-06 08:00:00 | 2024-01-06 09:00:00 |[
{"employee_id":10,"max_overlapping_shifts":2,"total_overlap_duration":60},
{"employee_id":11,"max_overlapping_shifts":1,"total_overlap_duration":0}
]For employee 10, the cross-midnight pair is ignored by the same-date bucketing rule (different DATE(start_time) values). The 08:00-12:00 windows on 2024-01-06 overlap for 60 minutes.
EmployeeShifts:
| employee_id | start_time | end_time |
|-------------|----------------------|----------------------|
| 20 | 2024-03-01 08:00:00 | 2024-03-01 12:00:00 |
| 20 | 2024-03-01 09:00:00 | 2024-03-01 11:00:00 |
| 20 | 2024-03-01 09:30:00 | 2024-03-01 10:30:00 |
| 20 | 2024-03-01 10:00:00 | 2024-03-01 13:00:00 |
| 21 | 2024-03-01 23:00:00 | 2024-03-01 23:59:00 |[
{"employee_id":20,"max_overlapping_shifts":4,"total_overlap_duration":450},
{"employee_id":21,"max_overlapping_shifts":1,"total_overlap_duration":0}
]Employee 20 reaches concurrency 4 and accumulates pairwise overlap contributions across each timeline segment. Employee 21 has only one shift.
Constraints