select *
from (select tstart,
tend,
lead(tstart) over(order by tstart) next_start,
lead(tend) over(order by tstart) next_end
from t1
where (tstart, tend) not in
(select a.tstart, a.tend
from t1 a, t1 b
where (a.tstart >= b.tstart and a.tend < b.tend)
or (a.tstart > b.tstart and a.tend <= b.tend)
or (a.tstart > b.tstart and a.tend < b.tend)))
where next_start > tend;
断点:23-24
TSTART | TEND | NEXT_START | NEXT_END |
19 | 23 | 24 | 30 |