题解 | #考试分数(四)#
考试分数(四)
http://www.nowcoder.com/practice/502fb6e2b1ad4e56aa2e0dd90c6edf3c
#窗口函数给出排名rank,rank值判断奇偶后,对每个job分组分别计数奇数个数及偶数个数,奇数个数即为start,偶数个数+1为end select job,sum(`rank`%2=1) `start`,sum(`rank`%2=0)+1 `end` from ( select *,dense_rank() over (partition by job order by score) `rank` from grade ) a group by job order by job;