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

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

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

select uid, round(avg(score), 0) as avg_score, round(avg((case when submit_time IS NULL then duration else TIMESTAMPDIFF(MINUTE, start_time, submit_time) end)), 1) as avg_time_took
from (
    select a.uid, a.exam_id, b.difficulty, b.duration, a.start_time, a.submit_time, a.score
    from (
        select uid, exam_id, start_time, submit_time, (case when score IS NULL then 0 else score end) as score
        from exam_record
        where uid in (
            select uid
            from user_info
            where level = 0
        )
    ) as a
    left join examination_info as b
    on a.exam_id = b.exam_id
    where b.difficulty = 'hard'
) as t1
group by uid;

全部评论
聚合函数中嵌套条件判断
点赞 回复 分享
发布于 2023-08-01 00:10 江苏

相关推荐

不愿透露姓名的神秘牛友
11-21 11:29
已编辑
斯卡蒂味的鱼汤:知道你不会来数马,就不捞你😂最近数马疯狂扩招,招聘要求挺低的,你能力肯定够,应该就是因为太强了,知道你不会来才不捞你
投递腾讯云智研发等公司7个岗位
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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