题解 | #统计每个学校各难度的用户平均刷题数#

统计每个学校各难度的用户平均刷题数

https://www.nowcoder.com/practice/5400df085a034f88b2e17941ab338ee8

方法1:三表左外连接

select
    c.university,
    b.difficult_level,
    count(a.device_id) / count(distinct a.device_id) as avg_answer_cnt
from
    question_practice_detail a
    left join question_detail b on a.question_id = b.question_id
    left join user_profile c on a.device_id = c.device_id
group by
    c.university,
    b.difficult_level

方法2:三表内连接

select
    c.university,
    b.difficult_level,
    count(a.device_id) / count(distinct a.device_id) as avg_answer_cnt
from
    question_practice_detail a,
    question_detail b,
    user_profile c
where a.question_id = b.question_id and a.device_id = c.device_id
group by
    c.university,
    b.difficult_level

全部评论

相关推荐

双非坐过牢:非佬,可以啊10.28笔试,11.06评估11.11,11.12两面,11.19oc➕offer
点赞 评论 收藏
分享
评论
1
收藏
分享
牛客网
牛客企业服务