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

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

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

select
    a.device_id,
    a.university,
    coalesce(b.answ_num_Aug, 0) as answ_num_Aug,
    coalesce(c.right_answ_num_Aug, 0) as right_answ_num_Aug
from
    (
        select
            device_id,
            university
        from
            user_profile
        where
            university = '复旦大学'
        group by
            1,
            2
    ) a
    left join (
        select
            device_id,
            count(question_id) as answ_num_Aug
        from
            question_practice_detail
        where
            date between '2021-08-01' and '2021-08-31'
        group by
            1
    ) b on a.device_id = b.device_id
    left join (
        select
            device_id,
            count(question_id) as right_answ_num_Aug
        from
            question_practice_detail
        where
            date between '2021-08-01' and '2021-08-31'
            and result = 'right'
        group by
            1
    ) c on a.device_Id = c.device_id

全部评论

相关推荐

06-25 16:25
梧州学院 Java
愿汐_:项目介绍那么长,然而你做了啥就一句话?
点赞 评论 收藏
分享
07-25 10:39
门头沟学院 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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