SQL to find time elapsed from multiple overlapping intervals
Not using MSSQL or DB2 or Oracle. No CTE. No OVERLAP predicate. No INTERVAL data type. The situation: on a vehicle to be repaired work can not start until all parts ordered for the job have been received. Parts may be ordered multiple times prior to the start of repair. We need to extract the time for which the vehicle was on "parts hold" So for a vehicle identified as id = 1 parts were ordered (d1) and received (d2) on 4 different occasions ID d1 d2 1 8/1 8/8 1 8/2 8/6 1 8/12 8/14 1 8/3 8/10 8/1 8/8 d1 d2 |-------------------------------| 8/2 8/6 8/12 8/14 d1 d2 d1 d2 |---------------| |-----