标创建语句
CREATE TABLE `my_t` (
`id` int(11) NOT NULL,
`value` int(11) DEFAULT NULL,
`key` varchar(10) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
插入数据
INSERT INTO `my_t` VALUES ('1', '100', 'A');
INSERT INTO `my_t` VALUES ('2', '200', 'A');
INSERT INTO `my_t` VALUES ('3', '200', 'B');
INSERT INTO `my_t` VALUES ('4', '300', 'B');
INSERT INTO `my_t` VALUES ('5', '200', 'A');
查询语句
select `key`,max(`value`) from my_t GROUP BY `key`;
select t.* from my_t t where (t.`key`,t.`value`) in (select `key`,max(`value`) from my_t GROUP BY `key`);