题解 | #未完成率较高的50%用户近三个月答卷情况#

未完成率较高的50%用户近三个月答卷情况

https://www.nowcoder.com/practice/3e598a2dcd854db8b1a3c48e5904fe1c

/*筛选出SQL完成率后50%的6级或7级用户*/
with t3 AS(
    select t2.uid
    from(
        select uid
                ,percent_rank() over(order by round(count(submit_time)/count(start_time),1) asc) AS incomplete_rate_rank
        from exam_record
        where exam_id in(
            select exam_id from examination_info where tag = 'SQL'
        )
        group by uid
    )t2
    inner join user_info ui on t2.uid = ui.uid
    where incomplete_rate_rank <= 0.5 and (level = 6 or level = 7)
)

select uid
        ,start_month
        ,total_cnt
        ,complete_cnt
from(
    select t3.uid
            ,date_format(start_time,'%Y%m') AS 'start_month'
            ,count(start_time) AS total_cnt
            ,count(submit_time) AS complete_cnt
            ,dense_rank() over(partition by t3.uid order by date_format(start_time,'%Y%m') desc) AS month_rank
    from t3 
    left join exam_record er on t3.uid = er.uid
    group by t3.uid
            ,date_format(start_time,'%Y%m') /*按照月份和uid统计每个月的试卷作答情况*/
    )t4 /*t4:每个用户每个月的SQL试卷作答情况,并且给月份排名*/
where month_rank <= 3
order by uid asc
        ,start_month asc

全部评论

相关推荐

10-21 00:37
已编辑
门头沟学院 C++
小浪_Coding:你问别人,本来就是有求于人,别人肯定没有义务免费回答你丫, 有点流量每天私信可能都十几,几十条的,大家都有工作和自己的事情, 付费也是正常的, 就像你请别人搭把手, 总得给人家买瓶水喝吧
点赞 评论 收藏
分享
10-14 21:00
门头沟学院 Java
吃花椒的狸猫:这个人说的倒是实话,特别是小公司,一个实习生哪里来的那么多要求
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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