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

分别满足两个活动的人

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#
全部评论

相关推荐

12-22 16:31
已编辑
桂林电子科技大学 Python
很奥的前端仔:如果你接了offer 临时又说不去 hr确实要多做一些工作。 当然如果是接offer之前当我没说
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
11-21 11:29
已编辑
斯卡蒂味的鱼汤:知道你不会来数马,就不捞你😂最近数马疯狂扩招,招聘要求挺低的,你能力肯定够,应该就是因为太强了,知道你不会来才不捞你
投递腾讯云智研发等公司7个岗位
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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