there is probably a better way to achieve this, but, this is a quick
solution
mysql> SELECT * FROM test where sallary IN (SELECT MAX(SALLARY) FROM test
GROUP BY company);
+++---+-+
| id | name | company | sallary |
+++---+-+
| 2 | Peter
the answer is exactly what you asked for.
It gave you the max salary per company and made a "lucky guess" (not really,
alfabetically first) as to which name you wanted since you never specified
this
of the top of my head, try this.
SELECT a.id,a.name,a.company,a.sallary FROM `test` a
,(select com