题解 | #分别满足两个活动的人#
分别满足两个活动的人
https://www.nowcoder.com/practice/a126cea91d7045e399b8ecdcadfb326f
SELECT * from (SELECT uid,'activity2' activity from ( SELECT er.*,ei.tag,ei.difficulty,ei.duration,TIMESTAMPDIFF(second,start_time,submit_time) subtime FROM `exam_record` er join examination_info ei on er.exam_id=ei.exam_id where score >80 and ei.difficulty='hard' )t1 where subtime<=duration*60/2 union SELECT distinct uid,'activity1' activity from exam_record where score>=85 GROUP BY uid HAVING MIN(score)>=85 )t2 ORDER BY uid,activity; #正确做法:按照分组最小值>80筛选出每一次答题都大于80分的uid SELECT distinct uid,'activity1' activity from exam_record where score>=85 GROUP BY uid HAVING MIN(score)>=85