title: SQL: Find the max record per group
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/1313120/retrieving-the-last-record-in-each-group">Retrieving the last record in each group</a>  </p>
  </blockquote>
  
  
  
  <p>I have one table, which has three fields and data.</p>
  
  <pre>
  Name  , Top , Total
  cat   ,   1 ,    10
  dog   ,   2 ,     7
  cat   ,   3 ,    20
  horse ,   4 ,     4
  cat   ,   5 ,    10
  dog   ,   6 ,     9
  </pre>
  
  <p>I want to select the record which has highest value of <code>Total</code> for each <code>Name</code>, so my result should be like this:</p>
  
  <pre>
  Name  , Top , Total
  cat   ,   3 ,    20
  horse ,   4 ,     4
  Dog   ,   6 ,     9
  </pre>
  
  <p>I tried group by name order by total, but it give top most record of group by result. Can anyone guide me, please?</p>