0 点赞 评论 收藏
分享
PiotrNewt:两个知识点:
- 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;
0 点赞 评论 收藏
分享

0 点赞 评论 收藏
分享

0 点赞 评论 收藏
分享

0 点赞 评论 收藏
分享
0 点赞 评论 收藏
分享

0 点赞 评论 收藏
分享
oklets:https://paste.ubuntu.com/p/2n5JJBQM7y/

0 点赞 评论 收藏
分享
0 点赞 评论 收藏
分享
0 点赞 评论 收藏
分享
创作者周榜
更多
关注他的用户也关注了: