MySQL Forums
Forum List  »  Newbie

How do you select only rows with max value?
Posted by: Max Loeb
Date: March 06, 2008 03:04PM

Given a table like this:

CREATE TABLE IF NOT EXISTS `people` (
`name` varchar(10) NOT NULL,
`age` smallint(5) unsigned NOT NULL,
PRIMARY KEY (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `people`
--

INSERT INTO `people` (`name`, `age`) VALUES
('bob', 13),
('john', 25),
('mike', 25),
('steve', 8),
('sue', 13);


How would I select only the rows with the highest 'age' value?
In other words, because "john" and "mike" are the oldest, I want only their rows.

Thanks much!
- Max

Options: ReplyQuote


Subject
Written By
Posted
How do you select only rows with max value?
March 06, 2008 03:04PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.