两个知识点: - group by 两个列 - group by 和 order by 同时使用 group by 两个列不用多说。group by 和 order by 同时使用的话,由于这里最后 select 的列中刚好不需要 score,不然 group by 配上一个 max 就很香: select name, class, coursename, max(score) from scoretable group by class, coursename; 不要 score 的话可以利用子查询先做 order by 再 group by,因为没有聚合函数 group by 天然返回第一行: select s.name, s.class, s.coursename from (select * from scoretable order by score desc) as s group by s.class, s.coursename;
1 3

相关推荐

快点约我面试吧
投递百度等公司10个岗位
点赞 评论 收藏
分享
仁者伍敌:牛子这些人还会点一个自动回复,boss都不带回复的
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务