title: How to select dates [not] between list of ranges
body: <p>I have a problem with an SQL query..My issue is that I have a list of date, such as :</p>
  
  <ul>
  <li>2015-06-23</li>
  <li>2015-06-24</li>
  <li>2015-06-25</li>
  <li>2015-06-26</li>
  <li>2015-06-27</li>
  <li>2015-06-28</li>
  </ul>
  
  <p>in a table named "days".</p>
  
  <p>I have another table "filter" which contains a list of range in two columns :</p>
  
  <pre><code>        start  |  end
         --------+---------
    2015-06-24   | 2015-06-24
    2015-06-26   | 2015-06-27
         ...     |  ...
  </code></pre>
  
  <p>What I'm trying to get as a result is :</p>
  
  <ul>
  <li>2015-06-23</li>
  <li>2015-06-25</li>
  <li>2015-06-28</li>
  </ul>
  
  <p>ie the dates that are not in these ranges.</p>
  
  <p>I tried this :</p>
  
  <pre><code>SELECT day.date
  FROM days, filter
  WHERE days.date not between filter.start and filter.end_time
  group by day.date
  </code></pre>
  
  <p>I thought this code might have done the trick but it appears it works only when there's one row in the filter table..In my case the number of range is not known at the beginning.</p>
  
  <p>I also noticed that, when removing the "group by" clause, the result was a list of repeating dates, where each date appeared once per filter validated. ie here :</p>
  
  <ul>
  <li>2x 2015-06-23 </li>
  <li>1x 2015-06-24</li>
  <li>2x 2015-06-25</li>
  <li>1x 2015-06-26</li>
  <li>1x 2015-06-27</li>
  <li>2x 2015-06-28</li>
  </ul>
  
  <p>Ohe solution might be to select only the rows that reach the maximum of occurrence, but there are my sql limits.. Plus I'm not sure this would be the most efficient way.</p>
  
  <p>Could someone help me with this please ?</p>