题解 | #统计每个用户的平均刷题数#

统计每个用户的平均刷题数

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

select
    '山东大学' as university,
    d.difficult_level,
    sum(ansNum) / count(d.device_id) as avg_answer_cnt
from
    (
        select
            a.device_id,
            c.difficult_level,
            count(1) as ansNum
        from
            user_profile a
            join question_practice_detail b on a.device_id = b.device_id
            and a.university = '山东大学'
            join question_detail c on b.question_id = c.question_id
        group by
            a.device_id,
            c.difficult_level
    ) d
group by
    d.difficult_level
order by
    avg_answer_cnt desc

暂时这样,优化再说

全部评论

相关推荐

09-08 17:17
同济大学 Java
狗不理fe:里面的人劝一句,别来虾,我们部门24校招生淘汰率30%,还有一些人说有一年保护期,不可能!!!
我的秋招日记
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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