# 输出2021年里 , 
# 所有每次试卷得分都能到85分的人 
# 至少有一次用了一半时间就完成高难度试卷且分数大于80的人的id和活动号 , 
# 按用户ID排序输出 。
select
    distinct uid,
    'activity1' as activity
from
    exam_record
where
    year(start_time) = '2021'
    and score >= 85

union all

select
    distinct a.uid,
    'activity2' as activity
from
    exam_record a
    inner join examination_info b using(exam_id)
where
    year(a.start_time) = '2021'
    and b.difficulty = 'hard'
    and a.score > 80
    and timestampdiff(second, a.start_time, a.submit_time) <= b.duration * 60 / 2
order by uid