我就不吃芹菜

导航

 

 

原始数据

--使用子查询
SELECT * FROM student s WHERE s.birthday IN (SELECT MIN(s2.birthday) FROM student s2 GROUP BY s2.major)

 

--使用row_number()函数
SELECT * FROM (SELECT s.*, row_number() OVER(PARTITION BY s.major ORDER BY s.birthday) hh FROM student s) r WHERE r.hh='1' --效率稍快

 

posted on 2017-12-17 01:19  我就不吃芹菜  阅读(2724)  评论(0编辑  收藏  举报