Possible Duplicate:
mysql: Using LIMIT within GROUP BY to get N results per group?
I have the following data.
id      val
smith   20
smith   10
smith    8
smith   30
jones   40
jones   10
jones   30
jones   30
What I want then is to group by id and sum the two largest values for each id.
smith   50  from 30+20
jones   70  from 40+30
Thanks.
 
     
    