select key, sum(val) from table group by key order by sum(val) desc read only the first record