题解 | #统计复旦用户8月练题情况#

统计复旦用户8月练题情况

https://www.nowcoder.com/practice/53235096538a456b9220fce120c062b3

select
    up.device_id,
    up.university,
    ifnull (a.question_cnt, 0) as question_cnt,
    ifnull (b.question_rightcnt, 0) as right_question_cnt
from
    user_profile up
    left join (
        select
            qpd.device_id,
            count(question_id) as question_cnt
        from
            question_practice_detail qpd
        where
            month (qpd.date) = 8
        group by
            qpd.device_id
    ) a on up.device_id = a.device_id
    left join (
        select
            qpd.device_id,
            qpd.result,
            count(result) as question_rightcnt
        from
            question_practice_detail qpd
        where
            qpd.result = 'right'
        group by
            qpd.device_id,
            qpd.result
    ) b on a.device_id = b.device_id
where
    up.university = '复旦大学';

全部评论

相关推荐

11-01 08:48
门头沟学院 C++
伤心的候选人在吵架:佬你不要的,能不能拿户口本证明过户给我。。球球了
点赞 评论 收藏
分享
11-03 14:38
重庆大学 Java
AAA求offer教程:我手都抬起来了又揣裤兜了
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务