DROP TABLE IF EXISTS `s_score`; CREATE TABLE `s_score` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(255) NOT NULL DEFAULT '', `subject` varchar(255) NOT NULL DEFAULT '', `score` float NOT NULL DEFAULT '0', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; INSERT INTO `s_score` (`id`, `name`, `subject`, `score`) VALUES (1, 'allen', '语文', 60), (2, 'allen', '数学', 75), (3, 'allen', '英语', 78), (4, 'tang', '语文', 67), (5, 'tang', '数学', 78), (6, 'tang', '英语', 88), (7, 'lily', '语文', 98), (8, 'lily', '数学', 87), (9, 'lily', '英语', 70);
查询每个人最优结果,结果包含 id,name,subject,score列。
select a.name,a.subject,a.score from (select id,name,subject,score from s_score order by score desc limit 1000) as a
group by a.name
本文原地址:https://www.eqiday.cn/253.html
郑重声明内容版权声明:除非注明,否则皆为本站原创文章。如有侵权联系进行删除!