I have data as follows in a Table ( 3 columns ):
Name StartDt EndDt
A 01/01/2009 12/31/2009
A 01/01/2010 11/30/2010
A 03/01/2011 10/31/2011
A 04/01/2012 12/31/2013
B 08/01/2013 12/12/2013
A 01/01/2014 08/01/2014
A 08/02/2014 05/14/2015
Now I want to create a Output using Terdata Sql query as follows:
Name Min_Startdt Max_Startdt
A 01/01/2009 11/30/2010
A 03/01/2011 10/31/2011
A 04/01/2012 12/31/2013
A 01/01/2014 05/14/2015
B 08/01/2013 12/12/2013
If u notice the First Row corresponding to Name=A in the Output is combination of first 2 rows of Input for Name=A since the Startdt and Enddt for these 2 rows are continous ie Enddt+1 of first row =Startdt of second row. Similarily the 4th row in output is a combination of 6th and 7th row in Input for Name=A. Remaining rows form the Input remain unchanged in the output.
Please let me how this can be achieved via a Teradata Query.