I have multiple date ranges in a table(i.e. TAB1) like below.
START_DATE | END_DATE
-------------------------
1-Jan-2004 | 31-Dec-2005
1-Jan-2001 | 31-Dec-2001
1-Jan-2011 | 31-Dec-2015
Now based on an input date range assuming it overlaps at least 1 row in the table, I want to change dates of existing rows.
Example 1 : If the input date range is 1-Jan-2012 | 31-Dec-2017 then Row-3 should be 1-Jan-2011 | 31-Dec-2017. Rest of the rows should be unchanged.
Example 2 : If the input date range is 1-Jan-2007 | 31-Dec-2012 then Row-3 should be 1-Jan-2007 | 31-Dec-2015. Rest of the rows should be unchanged.
Example 3 : If the input date range is 1-Jan-2009 | 31-Dec-2017 then Row-3 should be 1-Jan-2009 | 31-Dec-2017. Rest of the row should be unchanged.
Example 4 : If the input date range is 1-Jan-2005 | 31-Dec-2012 then Row-3 should be 1-Jan-2006 | 31-Dec-2015. Rest of the row should be unchanged.
Example 5 : If the input date range is 1-Jan-2003 | 31-Dec-2003 then Row-1 should be 1-Jan-2003 | 31-Dec-2005. Rest of the row should be unchanged.
Any suggestion of SQL query for above?