title: SQL Query Extract Totals by Month for Multiple Date Fields
body: <p>I have an Oracle Database I am trying to query multiple date fields by dates and get the totals by month and year as output. </p>
  
  <p>This was my original query. This just gets what I want for the dates I want to input.</p>
  
  <pre><code>SELECT COUNT(*) as Total
  FROM Some_Table s
  WHERE (s.Start_DATE &lt;= TO_Date ('2019/09/01', 'YYYY/MM/DD'))
  AND (s.End_DATE IS NULL OR (s.End_DATE &gt; TO_Date ('2019/08/31', 'YYYY/MM/DD')))
  </code></pre>
  
  <p>I would like to get an output where it gives me a count by Month and Year. The count would be the number between the Start_DATE (beginning of the month) and the End_DATE (end of the month).</p>
  
  <p>I can't do</p>
  
  <p>Edit: this was an example from another query and has no relation to the query above. I was just trying to provide an example of what I cannot do because I have two separate date fields. The example below was stating my knowledge of extracting month and year from a single date field. Sorry for the confusion.</p>
  
  <pre><code>SELECT extract(year from e.DATE_OCCURRED) as Year
        ,to_char(e.DATE_OCCURRED, 'MONTH') as Month
        ,count (*) as totals
  </code></pre>
  
  <p>because the Start_DATE and End_DATE are two separate fields.</p>
  
  <p>Any help would be appreciated</p>
  
  <p>Edit: Example would be</p>
  
  <pre><code>----------------------------------
  | Name | Start_DATE |  End_DATE  |
  ----------------------------------
  | John | 01/16/2018 | 07/09/2019 |
  | Sue  | 06/01/2015 | 09/01/2018 |
  | Joe  | 04/06/2016 |    Null    |
  ----------------------------------
  </code></pre>
  
  <p>I want to know my total number of workers that would have been working by month and year. Would want the output to look like.</p>
  
  <pre><code>------------------------
  | Year | Month | Total |
  ------------------------
  | 2016 |  Aug  |   2   |
  | 2018 |  May  |   3   |
  | 2019 |  Aug  |   2   |
  ------------------------
  </code></pre>
  
  <p>So I know I had two workers working in August 2016 and three in May 2018.</p>