Need help with sql Query

  • 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

    556868 1999-01-01 1999-06-30

    556868 1999-07-01 1999-10-31

    556869 2002-10-01 2004-01-31

    556872 1999-02-01 2000-08-31

    556872 2000-11-01 2004-01-31

    556872 2004-02-01 2004-02-29

    output should be ......

    ID effdate termdate

    556868 1999-01-01 1999-10-31

    556869 2002-10-01 2004-01-31

    556872 1999-02-01 2000-08-31

    556872 2000-11-01 2004-02-29

Viewing 0 posts

You must be logged in to reply to this topic. Login to reply