 <p>You can use the <code>collect_max</code> UDF from Brickhouse ( <a href="http://github.com/klout/brickhouse" rel="nofollow">http://github.com/klout/brickhouse</a> ) to solve this problem, passing in a value of 1, meaning that you only want the single max value.</p> <pre><code>select array_index( map_keys( collect_max( carrier_id, meandelay, 1) ), 0 ) from flightinfo; </code></pre> <p>Also, I've read somewhere that the Hive <code>max</code> UDF does allow you to access other fields on the row, but I think its easier just to use <code>collect_max</code>.</p>