I need help in writing the query for the following, I need to collapse the continuity. If the termdate for an ID is one day less than the effdate of the next id (for the same ID) i need to collapse the records. See below example .....how should i write the query which will give me the desired output. i.e., get min(effdate) and max(termdate) if termdate is one day less than the effdate of next record. Your help is appreciated. Thanks.
ID effdate termdate
5568681999-01-01 1999-06-30
5568681999-07-01 1999-10-31
5568692002-10-01 2004-01-31
5568721999-02-01 2000-08-31
5568722000-11-01 2004-01-31
5568722004-02-01 2004-02-29
output should be ......
ID effdate termdate
5568681999-01-01 1999-10-31
5568692002-10-01 2004-01-31
5568721999-02-01 2000-08-31
5568722000-11-01 2004-02-29