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

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

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

with t1 as
(
    select 
        a.device_id,
        university,
        question_id,
        result
    from user_profile a
    left join question_practice_detail b on a.device_id = b.device_id
    where university = "复旦大学" and month(date) = 8
)
select distinct
    device_id,
    university,
    count(1) over() question_cnt,
    sum(if(result = "right",1,0)) over() right_question_cnt
from t1

先筛选出来合适的然后去重,直接开窗计算结果了

全部评论

相关推荐

完美的潜伏者许愿简历通过:我上表jd,请求封我做后端大将军的事,北京有消息了:竟然不许!!! 他们一定是看我没有实习,这才故意驳回我的请求!
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务