Get ID of ROW when using aggregate functions

[email protected] ("Ondrej Kulaty")
Newsgroups php.db
Message-ID <[email protected]>
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  DEFAULT CHARSET=latin2 AUTO_INCREMENT=1 ;

With rows:

INSERT INTO `test` (`id`, `name`, `company`, `sallary`) VALUES
(1, 'Jane', 'Microsoft', 10000),
(2, 'Peter', 'Novell', 12000),
(3, 'Steven', 'Microsoft', 17000);

I want to select person from each company with a highest sallary.
I run this SQL:

SELECT id,name,company,MAX(sallary) FROM `test` GROUP BY company;

And result is:

id     name     company     MAX( sallary )
1     Jane       Microsoft   17000
2     Peter      Novell        12000

Why it returned Jane (id 1) as a person with highest sallary (17000) when 
obviously Jane has sallary of 10 000?

Thanks for any help.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.