题解 | #分别满足两个活动的人#

分别满足两个活动的人

https://www.nowcoder.com/practice/a126cea91d7045e399b8ecdcadfb326f

select 
uid,'activity1'
from exam_record a
left join examination_info b on a.exam_id=b.exam_id
where 
uid not in (select uid from exam_record where score<85)
and year(submit_time)='2021'

union 

select uid,'activity2'
from 
(
select 
uid
,score
,duration
,timestampdiff(second,start_time,submit_time)/60 diff -- 时间如果用分钟,比如40分钟59秒,返回40分,因此用秒更精确
from exam_record a
left join examination_info b on a.exam_id=b.exam_id
where year(submit_time)='2021'
and difficulty='hard'
and duration/2>=timestampdiff(second,start_time,submit_time)/60
) t
where diff >=0 and score>80







#MySQL#
全部评论

相关推荐

07-02 13:50
闽江学院 Java
点赞 评论 收藏
分享
05-09 14:45
门头沟学院 Java
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务