A little fix: with t ( ID , START_DATE , END_DATE ) as ( select 1 , date'2015-01-01' , date'2015-02-01' from dual union all select 1 , date'2015-01-05' , date'2015-01-06' from dual union all select 1 , date'2015-01-11' , date'2015-01-20' from dual union all select 1 , date'2015-01-22' , date'2015-02-25' from dual union all select 2 , date'2020-01-01' , date'2020-01-15' from dual union all select 2 , date'2020-01-15' , date'2020-02-01' from dual union all select 2 , date'2020-03-01' , date'2020-04-01' from dual union all select 2 , date'2020-03-05' , date'2020-03-11' from dual ) select id,min(start_date),max(end_date) from ( select id,start_date,end_date ,count(start_of_group) over(partition by id order by start_date) grp from ( select id,start_date,end_date ,case when start_date<=max(end_date)over(partition by id order by start_date*,end_date* rows between unbounded preceding and 1 preceding) then null else 0 end start_of_group from t ) v1 ) v2 group by id,grp order by id,grp -- Best regards, Sayan Malakshinov http://orasql.org