title: Find matching interval in SQL - Oracle
body: <p>I have a table:</p>
  
  <p>table:</p>
  
  <pre><code>start         end
  1 Jan 09    31 Jan 2009
  1 Feb 09    28 Feb 2009
  1 Mar 09    31 Mar 2009
  1 Apr 09    01 May 2009
  1 May 09    31 May 2009
  1 Jun 09    01 Jul 2009
  1 Jul 09    31 Jul 2009
  1 Aug 09    31 Aug 2009
  1 Sep 09    01 Oct 2009
  1 Oct 09    31 Oct 2009
  1 Nov 09    01 Dec 2009
  1 Dec 09    31 Dec 2009
  1 Jan 10    31 Jan 2010
  1 Feb 10    03 Mar 2010
  1 Mar 10    31 Mar 2010
  1 Apr 10    01 May 2010
  1 May 10    31 May 2010
  1 Jun 10    01 Jul 2010
  1 Jul 10    31 Jul 2010
  1 Aug 10    31 Aug 2010
  1 Sep 10    01 Oct 2010
  1 Oct 10    31 Oct 2010
  1 Nov 10    01 Dec 2010
  1 Dec 10    31 Dec 2010
  1 Jan 09    31 Mar 2009
  1 Apr 09    30 Jun 2009
  1 Jul 09    01 Oct 2009
  1 Oct 09    31 Dec 2009
  1 Jan 10    31 Mar 2010
  1 Apr 10    30 Jun 2010
  1 Jul 10    01 Oct 2010
  1 Oct 10    31 Dec 2010
  1 Jan 09    31 Dec 2009
  1 Jan 10    31 Dec 2010
  </code></pre>
  
  <p>The above contains for each month, quarter and year of 2009, 2010.</p>
  
  <p>I have another table with the following:</p>
  
  <p>table2</p>
  
  <pre><code>start       end
  15-12-09    31-12-09
  15-01-12    31-12-13
  01-01-11    31-12-13
  30-01-98    31-12-13
  01-01-98    31-12-13
  01-01-98    31-12-13
  23-12-12    31-12-13
  12-11-11    31-12-13
  01-01-10    31-12-13
  </code></pre>
  
  <p>For each entry in table2, I need to find the possible timeframes it falls into table1.</p>
  
  <p>For ex. from table2, first entry - </p>
  
  <pre><code>15-12-09    31-12-09
  </code></pre>
  
  <p>falls to:</p>
  
  <pre><code>1 Dec 09    31 Dec 2009
  1 Oct 09    31 Dec 2009
  1 Jan 09    31 Dec 2009
  </code></pre>
  
  <p>Is it possible in Oracle SQL to identify it?</p>