title: Complex Group by Query in hive
body: <p>I have dataset in hive table like below</p>
  
  <pre><code>date           col1      col2  col3
  2016-02-01      A         X     5 
  2016-02-03      A         X     5
  2016-02-04      A         X     5
  2016-03-01      A         X     6
  2016-04-01      A         X     5
  2016-04-02      A         Y     5
  2016-04-03      A         Y     5
  </code></pre>
  
  <p>I have  to do selective grouping on col 1 and col2 where in one group is formed whenever col3 value changes , for example col3 value is changed from 5 to 6 in row4 , I have to take the date column and get the min and max values out of it.
  the output should be like this . </p>
  
  <pre><code>col1 col2 col3    minDate           maxDate
  A     X    5     2016-02-01         2016-02-04
  A     X    6     2016-03-01         2016-03-01
  A     X    5     2016-04-01         2016-04-01
  A     Y    5     2016-04-02         2016-04-03  
  </code></pre>
  
  <p>I am sure simple group by on col1 and col2 can not work.
  Can anyone please suggest a way to achieve this please ?</p>