select uid,'activity1' as activity from exam_record where year(start_time)=2021 group by uid having avg(score) >=85 union all select uid,'activity2' as activity from exam_record t join examination_info t1 using(exam_id) where difficulty = 'hard' and TIMESTAMPDIFF(second,start_time,submit_time) <= t1.duration*30 and score >80 and year(start_time)= 2021 order by uid
这道题核心的点就是 时间差如何求的
TIMESTAMPDIFF(second/minute,starttime,endtime)
这道题不用使用分钟来求,会忽略道秒的细节,导致出错。