I have a table called Customers, This table has CustomerName, Order, and Order Date:
Customer1 Order A 1/1/2006
Order B 1/6/2006
Order C 1/1/2009
Customer2 Order A 1/1/2007
Order B 1/1/2010
Order C 1/6/2010
We are not interested in records that their Order date difference is more than two years. In other words we only keep records that their order happens in two year period. For example: in the above situation, we can keep the Customer1,Order A, 1/1/2006, because in less than two years there was an order. The same for Customer 1, Order B 1/6/2006 because less than 2 years ago there was a order. however, we shouldn't keep Customer1, Order C, 1/1/2009 because in a two year time span(before and after) there was no order. So we delete it from table.
The same logic for Customer 2, which means, first records for Customer 2,Order A,1/1/2007 will be deleted.
I don't know how to implement this, Can anyone help me out? I would really appreciate it.
Thanks,
Customer1 Order A 1/1/2006
Order B 1/6/2006
Order C 1/1/2009
Customer2 Order A 1/1/2007
Order B 1/1/2010
Order C 1/6/2010
We are not interested in records that their Order date difference is more than two years. In other words we only keep records that their order happens in two year period. For example: in the above situation, we can keep the Customer1,Order A, 1/1/2006, because in less than two years there was an order. The same for Customer 1, Order B 1/6/2006 because less than 2 years ago there was a order. however, we shouldn't keep Customer1, Order C, 1/1/2009 because in a two year time span(before and after) there was no order. So we delete it from table.
The same logic for Customer 2, which means, first records for Customer 2,Order A,1/1/2007 will be deleted.
I don't know how to implement this, Can anyone help me out? I would really appreciate it.
Thanks,
Comment