title: SELECT MAX() and corresponding field in the same row
body: <p>Here's my table A</p>
  
  <pre><code>orderID groupID   nameID
  1       grade A   foo
  2       grade A   bar
  3       grade A   rain
  1       grade B   rain
  2       grade B   foo
  3       grade B   bar
  1       grade C   rain
  2       grade C   bar
  3       grade C   foo
  </code></pre>
  
  <p>Desired result:</p>
  
  <pre><code>rain
  bar
  foo
  </code></pre>
  
  <p>I need <code>nameID</code> of <code>max(orderID)</code> from each grade. I can get right <code>orderID</code> from each grade, but <code>nameID</code> always stays as the first.</p>
  
  <p>Thanks a Lot!</p>
  
  <hr>
  
  <p>Praveen gave the right query! Extra question under his answer</p>