title: hive sql find the latest record
body: <p>the table is:</p>
  
  <pre><code>create table test (
  id string,
  name string,
  age string,
  modified string)
  </code></pre>
  
  <p>data like this:</p>
  
  <pre><code>id    name   age  modifed
  1     a      10   2011-11-11 11:11:11
  1     a      11   2012-11-11 12:00:00
  2     b      20   2012-12-10 10:11:12
  2     b      20   2012-12-10 10:11:12
  2     b      20   2012-12-12 10:11:12
  2     b      20   2012-12-15 10:11:12
  </code></pre>
  
  <p>I want to get the latest record(include every colums id,name,age,modifed) group by id,as the data above,the correct result is:</p>
  
  <pre><code>1     a      11   2012-11-11 12:00:00
  2     b      20   2012-12-15 10:11:12
  </code></pre>
  
  <p>I do like this:</p>
  
  <pre><code>insert overwrite table t 
  select b.id, b.name, b.age, b.modified 
  from (
          select id,max(modified) as modified 
          from test 
          group by id
  ) a 
  left outer join test b on (a.id=b.id  and a.modified=b.modified);
  </code></pre>
  
  <p>This sql can get the right result,but when mass data，it runs slow.</p>
  
  <p>**Is there any way to do this without left outer join? **</p>