title: Hive SQL - Retrieve distinct values for a column existing in a date range
body: <p>I have a table in Hive as follows:</p>
  
  <pre><code>|attribute | start_date | end_date   | 
  |----------+------------+------------+ 
  | x        | 10-01-2014 | 03-31-2015 | 
  | x        | 04-01-2015 | 09-30-2015 | 
  | x        | 10-01-2015 | 03-31-2016 |
  | x        | 04-01-2016 | 09-30-2016 |
  | y        | 10-01-2015 | 03-31-2016 | 
  | y        | 04-01-2016 | 09-30-2015 |
  </code></pre>
  
  <p>I want to get a distinct list of only all attributes that have occured between 10-01-2014 and 09-30-2016 but they must have a start date in each of (10-01-2014, 04-01-2015, 10-01-2015, 04-01-2016).</p>
  
  <p>I tried:</p>
  
  <pre><code>select distinct(attribute),min(start_date) ,max(end_date) 
  from table 
  where 
      max(end_date) &gt;='03-31-2016' 
      and min(effective_start_date) &lt;='2015-01-01'
  </code></pre>
  
  <p>but that doesn't prevent any gaps. Any help would be greatly appreciated.</p>