题解 | #分别满足两个活动的人#
分别满足两个活动的人
https://www.nowcoder.com/practice/a126cea91d7045e399b8ecdcadfb326f
select uid,'activity1' activity from exam_record er join examination_info ei on er.exam_id=ei.exam_id where uid not in (select uid from exam_record where score<85) and year(start_time)=2021 union select uid,'activity2' activity from exam_record er join examination_info ei on er.exam_id=ei.exam_id where timestampdiff(second,start_time,submit_time)<=duration*30 and score>80 and difficulty='hard' and year(start_time)=2021 order by uid;
成绩全部大于等于85,只要uid不在有一个成绩小于85的组中就行
timestampdiff(unit,begin,end),返回end-begin的结果,单位为unit(如second,minute等)