Hi,
I have following table:
id int(11)
name varchar(255)
company varchar(255)
sallary int(11)
CREATE TABLE `test` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`company` varchar(255) NOT NULL,
`sallary` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM
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
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