title: Select and group multiple range of dates in oracle SQL
body: <p>I want to Select the same range of dates and group them by year. In this case I want the total of the bills of a customer per year from September and October. </p>
  
  <p>My Code right now:</p>
  
  <pre><code>SELECT c.name, c.telefonnumber, TO_CHAR(b.billdate, 'YYYY'), sum(b.sume)
  FROM customer c, bill b
  WHERE b.customerId = c.id
  AND b.datum BETWEEN '01.10.2016' AND '30.09.2016'
  GROUP BY c.name, c.telefonnumber, TO_CHAR(b.billdate, 'YYYY');
  </code></pre>
  
  <p>This Query works perfectly but when I want to add another year the result is an endless loop:</p>
  
  <pre><code>AND b.datum BETWEEN '01.10.2016' AND '30.09.2016'
  OR b.datum BETWEEN '01.10.2015' AND '30.09.2015'
  </code></pre>
  
  <p>I also tried to do it in a String way. In this case when I only look for the results of September it works perfectly, but again as soon as I add the <strong>OR</strong> it becomes again an endless loop:</p>
  
  <pre><code>AND TO_CHAR(kp.tmstmp) LIKE '%.09.%' 
  OR TO_CHAR(kp.tmstmp) LIKE '%.10.%' 
  </code></pre>
  
  <p>I know I am somehow missing something in the OR operator, but since this is only happening me with dates I am a bit confused. </p>