I have duplicate records in my table with below 3 scenario:
record Adddate
22344222 2016-04-22 00:00:00.000
22344222 2016-05-06 00:00:00.000
22344222 2016-06-06 00:00:00.000
22344222 2016-06-20 00:00:00.000
22344222 2016-07-25 00:00:00.000
22344222 2016-09-26 00:00:00.000
22344222 2016-10-03 00:00:00.000
22344222 2016-10-26 00:00:00.000
22344222 2016-10-27 00:00:00.000
22344222 2016-10-28 00:00:00.000
22344223 2016-04-22 00:00:00.000
22344223 2016-04-22 00:00:00.000
22344223 2016-04-22 00:00:00.000
22344223 2016-04-22 00:00:00.000
22344223 2016-04-22 00:00:00.000
22344223 2016-04-22 00:00:00.000
22344223 2016-04-22 00:00:00.000
22344223 2016-04-22 00:00:00.000
22344223 2016-04-22 00:00:00.000
22344223 2016-04-22 00:00:00.000
22344224 2016-04-22 00:00:00.000
22344224 2016-04-23 00:00:00.000
22344224 2016-04-24 00:00:00.000
22344224 2016-04-25 00:00:00.000
22344224 2016-04-26 00:00:00.000
22344224 2016-06-10 00:00:00.000
I want to delete all the duplicate records except for the 2 rows where the 1st row should be the one having least add date and the 2nd row where the date difference between the adddate is having 45 days.
In the above three scenario I should be able to preserve only the below data
record Adddate
22344222 2016-04-22 00:00:00.000
22344222 2016-05-06 00:00:00.000
22344223 2016-04-22 00:00:00.000
22344224 2016-04-22 00:00:00.000
22344224 2016-06-06 00:00:00.000