题解 | #分别满足两个活动的人#
分别满足两个活动的人
http://www.nowcoder.com/practice/a126cea91d7045e399b8ecdcadfb326f
SELECT uid, 'activity1' as activity from exam_record WHERE left(start_time,4)='2021' #第一问答案 group by uid having min(score)>=85 union all SELECT distinct uid, 'activity2' as activity from examination_info e1 left join exam_record e2 on e1.exam_id=e2.exam_id WHERE TIMESTAMPDIFF(MINUTE,e2.start_time,e2.submit_time)<e1.duration/2 #第二问答案 and e1.difficulty='hard' and e2.score>80 and left(e2.submit_time,4)='2021' order by uid 题目有2部分 1.拆解分析 求2021年考试中,所有成绩大于等于85的人,用activity1标注出来。 2.求用掉考试时间一般提交的,成绩大于80分,难度:为困难的人,用activity2标识出来。