title: Selecting MAX over multiple dependent fields
body: <p>Here's a sample of the data I wish to select from in the <code>AFRU</code> table. </p>
  
  <pre><code>+----------------------+-----------------+-------------------------+
  | Confirmation (RUECK) | Counter (RMZHL) | Finish Execution (IEDD) |
  +----------------------+-----------------+-------------------------+
  |                30116 |               1 | 08/26/2014              |
  |                30116 |               2 | 08/27/2014              |
  |                30116 |               3 | 09/27/2013              |
  +----------------------+-----------------+-------------------------+
  </code></pre>
  
  <p>Given this data set, I'd like to select the last row because it contains highest <code>RMZHL</code> value (I'm really only after the <code>IEDD</code> value of that record). Here's the code I've been trying to use:</p>
  
  <pre><code>SELECT MAX( rmzhl ), iedd FROM afru
                            INTO (@DATA(lv_rmzhl), @DATA(lv_iedd))
                            WHERE rueck = '0000030116'
        GROUP BY rmzhl, iedd.
        ...
        &lt;some fancy code here&gt;
        ...
  ENDSELECT.
  </code></pre>
  
  <p>However, this selection always nets me the values <code>1</code> for <code>lv_rmzhl</code>, and <code>20140826</code> for <code>lv_iedd</code>, therefore not getting the <code>MAX</code> value like I'm attempting to get. I understand that his could be easily accomplished by putting it all into an internal table and sorting on the <code>RMZHL</code> field, but I'm looking for a more proper way.</p>