题解 | #每类试卷得分前3名#
每类试卷得分前3名
http://www.nowcoder.com/practice/255aa1863fe14aa88694c09ebbc1dbca
(select tag,uid,rank()over( order by g desc,d desc,uid desc) from(select tag,uid,max(score) g,min(score) d from examination_info join exam_record using(exam_id) where score is not null and tag='C++' group by uid) a limit 3) union (select tag,uid,rank()over( order by g desc,d desc,uid desc) from(select tag,uid,max(score) g,min(score) d from examination_info join exam_record using(exam_id) where score is not null and tag='SQL' group by uid) a limit 3) union (select tag,uid,dense_rank()over( order by g desc,d desc,uid desc) from(select tag,uid,max(score) g,min(score) d from examination_info join exam_record using(exam_id) where score is not null and tag='算法' group by uid) a limit 3)