title: Number of unique dates
body: <p>There is table:</p>
  
  <pre><code>CREATE TABLE my_table 
    (gr_id      NUMBER,
     start_date DATE,
     end_date   DATE);
  </code></pre>
  
  <p>All dates always have zero time portion. I need to know a fastest way to compute number of unique dates inside gr_id. </p>
  
  <p>For example, if there is rows (dd.mm.rrrr):</p>
  
  <pre><code>1 | 01.01.2000 | 07.01.2000
  1 | 01.01.2000 | 07.01.2000
  2 | 01.01.2000 | 03.01.2000
  2 | 05.01.2000 | 07.01.2000
  3 | 01.01.2000 | 04.01.2000
  3 | 03.01.2000 | 05.01.2000
  </code></pre>
  
  <p>then right answer will be </p>
  
  <pre><code>1 | 7 
  2 | 6 
  3 | 5
  </code></pre>
  
  <p>At now I use additional table</p>
  
  <pre><code>CREATE TABLE mfr_date_list
     (MFR_DATE DATE);
  </code></pre>
  
  <p>with every date between 01.01.2000 and 31.12.2020 and query like this:</p>
  
  <pre><code>SELECT COUNT(DISTINCT mfr_date_list.mfr_date) cnt, 
         dt.gr_id
    FROM dwh_mfr.mfr_date_list,
          (SELECT gr_id, 
                  start_date AS sd, 
                  end_date AS ed
                 FROM my_table
          ) dt
   WHERE mfr_date_list.mfr_date BETWEEN dt.sd AND dt.ed
     AND dt.ed IS NOT NULL
   GROUP BY dt.gr_id
  </code></pre>
  
  <p>This query return correct resul data set, but I think it's not fastest way. I think there is some way to build query withot table mfr_date_list at all.</p>
  
  <p>Oracle 11.2 64-bit.</p>