题解 | #0级用户高难度试卷的平均用时和平均得分#

0级用户高难度试卷的平均用时和平均得分

http://www.nowcoder.com/practice/bb474c6cbd77478fb6d9fc86934d0ebb

本题知识点 case when 和if函数的应用
select t5.uid,round(avg(score),0),round(avg(took),1)
from 
    (select t4.uid uid,
           case when score is null then 0
           else score end as score,
           if(submit_time is null,duration,timestampdiff(minute,start_time,submit_time)) as took
    from 
        (select t1.uid uid,start_time,submit_time,duration,score
        from exam_record t1
        join examination_info t2
        on t1.exam_id=t2.exam_id
        join user_info t3
        on t1.uid=t3.uid
        where level=0 and difficulty='hard'
        ) t4
    ) t5
group by t5.uid;


全部评论

相关推荐

2025-12-26 10:52
河北传媒学院 Java
点赞 评论 收藏
分享
01-26 19:51
门头沟学院 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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