Would you like:
INSERT INTO finaltable SELECT gp, val FROM temp where gp = 'A' ORDER BY valDESC LIMIT 2;
best regardsR.Hnat