I have sample data in oracle database shown below :

```
set_no  set_eff_dt    set_term_dt
1000    1/1/2015    12/31/2016
1000    1/1/2017    10/31/2017
1000    11/1/2017   12/31/2018
1000    2/1/2019    10/31/2019
1000    11/1/2019   10/31/2020

```

I want the Out Like below

```
1000    1/1/2015    12/31/2018
1000    2/1/2019    10/31/2020

```

Let me Explain the Pattern and how the out put will Come

In the second row `set_off_dt` is result of `set_term_dt +1`

In the third row `set_off_dt` is result of `set_term_dt +1` of second row

In the 4th row `set_eff_dt` is not a result of `set_term_dt+1` from third row so here is group break may b

In the 5th row `set_eff_dt` is again a result of `set_term_dt+1` from 4th row 
so it will be collapsed with 4th row as shown in output 

In this same pattern we have thousand of records and we want to collapsed as per logic described

```
what i have tried

SELECT SET_NO,SET_EFF_DT,
 case when LEAD (SET_EFF_DT,1) OVER (ORDER BY SET_EFF_DT)-1 = set_trm_dt then 1 else 0 end flg
 FROM xx_fl_test

```

I was just able to identify the flag if `SET_EFF_DT` = `set_trm_dt` in new row... But still i dont got understand how tackle the collapsed on behalf of this data.