题解 | #统计复旦用户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

全部评论

相关推荐

北枳的南橘:建议大家务必去和他沟通一下,像极了小学生对你侃侃而谈国际局势😂
找AI工作可以去哪些公司...
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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