SQL to Perform the SCD Type 2 Operations

  • Consider the Sample Source Data -

    ID|START_DATE|VALUE

    110333005|2000-05-03 00:00:00.000000|0.00

    110333005|2014-01-08 12:38:40.000000|0.00

    110333005|2014-01-10 20:26:58.000000|103.14

    110333005|2014-01-22 07:50:20.000000|0.00

    110333005|2014-01-28 23:19:42.000000|0.00

    110333005|2014-02-10 15:49:52.000000|110.87

    110333005|2014-02-25 06:45:08.000000|0.00

    110333005|2014-03-10 14:34:57.000000|103.14

    Now I want to Retain the Most Top Value within a Consecutive Group, I mean to say when similar Data in "Value" comes consecutively it must retain the Oldest and also i need t consider when the Same value comes after some otehr value it should be inserted and not ignored.

    The Output i am looking for is :

    ID|START_DATE|VALUE

    110333005|2000-05-03 00:00:00.000000|0.00

    110333005|2014-01-10 20:26:58.000000|103.14

    110333005|2014-01-22 07:50:20.000000|0.00

    110333005|2014-02-10 15:49:52.000000|110.87

    110333005|2014-02-25 06:45:08.000000|0.00

    110333005|2014-03-10 14:34:57.000000|103.14

    Suggest How this can be achieved.

Viewing 0 posts

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