I have a query that returns this results
-----------------------------------------------------------------
|ID |ID1|ID2|IDP|IDC|IDA|START_DATE |END_DATE |
-----------------------------------------------------------------
|10 |2 |1 |10 |152|15 |1900-01-01 08:10:00|1900-01-01 09:10:00|
|10 |2 |1 |20 |152|12 |1900-01-01 09:10:00|1900-01-01 10:10:00|
|10 |2 |1 |30 |152|11 |1900-01-01 10:10:00|1900-01-01 11:10:00|
|10 |2 |1 |10 |152|15 |1900-01-01 11:10:00|1900-01-01 12:10:00|
|10 |2 |1 |10 |152|15 |1900-01-01 12:10:00|1900-01-01 13:10:00|
-----------------------------------------------------------------
I need to merge the last 2 rows because the END_DATE of the fourth row is equal to the START_DATE of fifth row. The other rows are all right and they have to be like that. So I would like to have this result.
-----------------------------------------------------------------
|ID |ID1|ID2|IDP|IDC|IDA|START_DATE |END_DATE |
-----------------------------------------------------------------
|10 |2 |1 |10 |152|15 |1900-01-01 08:10:00|1900-01-01 09:10:00|
|10 |2 |1 |20 |152|12 |1900-01-01 09:10:00|1900-01-01 10:10:00|
|10 |2 |1 |30 |152|11 |1900-01-01 10:10:00|1900-01-01 11:10:00|
|10 |2 |1 |10 |152|15 |1900-01-01 11:10:00|1900-01-01 13:10:00|
-----------------------------------------------------------------
With the fourth and fifth rows
-----------------------------------------------------------------
|10 |2 |1 |10 |152|15 |1900-01-01 11:10:00|1900-01-01 12:10:00|
|10 |2 |1 |10 |152|15 |1900-01-01 12:10:00|1900-01-01 13:10:00|
-----------------------------------------------------------------
They have to became only one
-----------------------------------------------------------------
|10 |2 |1 |10 |152|15 |1900-01-01 11:10:00|1900-01-01 13:10:00|
-----------------------------------------------------------------
How can I do that?