title: Hive query to get min and max of date column group by year and id
body: <p>I have table with two columns ,id and date.I want to get the max and min dates for that particular id as per that year. Below is the sample data and the result I wanted 
  Sample Data</p>
  
  <pre><code>id  date_col
  
  123 2015-05-01 04:00:00
  
  123 2017-04-01 04:00:00
  
  123 2017-09-01 04:00:00
  
  123 2014-09-01 04:00:00
  
  123 2012-12-01 05:00:00
  
  123 2016-08-01 04:00:00
  
  123 2014-05-01 04:00:00
  
  123 2016-10-01 04:00:00
  </code></pre>
  
  <p>Results I am expecting</p>
  
  <pre><code>123 2014-05-01   2014-09-01
  
  123 2015-05-01
  
  123 2016-08-01   2016-10-01
  
  123 2017-04-01   2017-09-01
  </code></pre>
  
  <p>I tried by using below multiple query but i won't be sorting according to the year</p>
  
  <pre><code>SELECT id,MAX(date_col) AS maxdate_col,MIN(date_col) AS mindate_col FROM table GROUP BY id 
  
  SELECT id,MAX(date_col) AS max_votes,MIN(date_col) AS mindate_col,YEAR(date_col) FROM test GROUP BY id,YEAR(date_col) 
  </code></pre>