题解 | #分别满足两个活动的人#
分别满足两个活动的人
http://www.nowcoder.com/practice/a126cea91d7045e399b8ecdcadfb326f
TIMESTAMPDIFF的minute参数有坑,分钟是直接截断的,为了准确用seconds参数
select
uid,
'activity1' as activity
from exam_record
group by uid
having min(score) >= 85
union all
select
distinct uid as uid,
'activity2' as activity
from exam_record a
inner join examination_info b on a.exam_id=b.exam_id
where b.difficulty='hard'
and (b.duration*60/2 - TIMESTAMPDIFF(SECOND, start_time, submit_time)) >= 0
and score > 80
order by uid