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

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

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

select 
        a.device_id,
        a.university,
        count(question_id) as question_cnt,
        sum(if(result='right',1,0)) as right_question_cnt  -- 也可以count搭配case when
from
    (-- 筛选出复旦大学的
     select 
        device_id, 
        university 
    from user_profile 
    where university='复旦大学') a
left join 
    (-- 筛选出8月份答题的
    select 
        device_id,
        question_id,
        result
    from question_practice_detail
    where month(date)=8 ) b
on a.device_id=b.device_id
group by a.device_id, a.university
全部评论

相关推荐

2025-12-22 16:31
已编辑
桂林电子科技大学 Python
很奥的前端仔:如果你接了offer 临时又说不去 hr确实要多做一些工作。 当然如果是接offer之前当我没说
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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