title: SQL:How return record by look up max assign column?
body: <p>data soure:</p>
  
  <pre><code>id  data1   data2
  1   1       4
  2   1       5
  3   2       6
  4   2       7
  </code></pre>
  
  <p>I need find data2 max and same data1. I hope return:</p>
  
  <pre><code>data1   id  data2
  1       2   5
  2       4   7
  </code></pre>
  
  <p>I try to: <code>select data1, id, max(data2) from table1 group by data1, id</code>.
  But it false.</p>
  
  <p>Is there another way to do this?    </p>