What SQL query would you use to find overlapping intervals in a table?
Assume intervals belong to a resource and have a start and end timestamp. Treat intervals that only touch at a boundary as non-overlapping, and exclude rows with missing or invalid bounds.
resource_id, interval_a_id, interval_b_id, overlap_start, and overlap_endresource_id, overlap_start, interval_a_id, and interval_b_id| Column | Type | Description |
|---|---|---|
| interval_idPK | INT | Unique interval identifier |
| resource_id | VARCHAR(30) | Resource to which the interval belongs |
| start_at | TIMESTAMP | Interval start timestamp |
| end_at | TIMESTAMP | Interval end timestamp |