美文网首页
sql distinct 取结果第一行

sql distinct 取结果第一行

作者: 小铭铭_7c47 | 来源:发表于2019-01-14 14:10 被阅读0次

取每种性别的 第一个学生:
select * from student where student_id in(Select min(student_id) FROM student group by sex)

数据库student表:


Snip20190114_3.png

查询结果:


Snip20190114_2.png

参考:
https://www.jianshu.com/p/7c2135d1d2af

相关文章

网友评论

      本文标题:sql distinct 取结果第一行

      本文链接:https://www.haomeiwen.com/subject/ttgddqtx.html