楼主的意思是估计是把重复时间段去掉,然后去最初的时间和最迟的时间 比如 start end 1 3 2 4 3 5 合并起来就只有 start end 1 5 其他的2,3,4属于重复时间段
with tt as( select 1 time_start,3 end_time from dual union all select 2,4 from dual union all select 3,5 from dual union all select 5,8 from dual union all select 9,11 from dual)select min(time_start),max(end_time) from tt t start with not exists( select 1 from tt where time_start<t.time_start and end_time>t.time_start) connect by prior end_time>time_start and prior end_time<end_time group by connect_by_root time_startMIN(TIME_START) MAX(END_TIME) 1 5 5 8 9 11
猜楼主的意思比sql本身更难
比如
start end
1 3
2 4
3 5
合并起来就只有
start end
1 5
其他的2,3,4属于重复时间段
select 1 time_start,3 end_time from dual
union all select 2,4 from dual
union all select 3,5 from dual
union all select 5,8 from dual
union all select 9,11 from dual)select min(time_start),max(end_time) from tt t
start with not exists(
select 1 from tt where time_start<t.time_start and end_time>t.time_start)
connect by prior end_time>time_start and prior end_time<end_time
group by connect_by_root time_startMIN(TIME_START) MAX(END_TIME)
1 5
5 8
9 11