Need Help: How to merge two overlapping date when date not consecutive.
1001168Apr 4 2013 — edited Apr 5 2013Hi,
I have following example data :
Customer_Id Opt_In_DT Opt_Out_DT
test1 1997-11-01 1997-11-31
test1 1999-07-01 2003-09-30
test1 2003-03-10 2007-04-08
test1 2003-10-01 2003-10-31
test1 2003-11-01 2004-10-31
test1 2005-11-01 2010-03-31
And I would like to have the data as following way. when we find overlapping period that should be merge to one. And if we dont have overlapping date then that should be loaded as it is.
Customer_Id Opt_In_DT Opt_Out_DT
test1 1997-11-01 1997-11-31
test1 1999-07-01 2010-03-31
I have tried to use the LAG function but that only work if we have the dates coming consecutively, If the order breaks then that function dont work.
Any suggestion to accomplish the overlapping date to one task.
Thanks,
Ram
Edited by: 998165 on Apr 4, 2013 4:15 PM