题解 | 未完成率top50%用户近三个月答卷情况

未完成率top50%用户近三个月答卷情况

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

with t as(
select uid,sum(if(submit_time is null,1,0)) as incomplete_cnt,count(start_time) as total_cnt,sum(if(submit_time is null,1,0))/count(start_time) as incomplete_rate,row_number() over(order by sum(if(submit_time is null,1,0))/count(start_time) desc) as rk from exam_record left join examination_info using(exam_id) where tag='SQL' group by 1),
t1 as (
select uid from t left join user_info using(uid) where rk<= round((select max(rk) from t)/2) and level in (6,7))

select uid,start_month,total_cnt,complete_cnt from(
select uid,DATE_FORMAT(start_time,'%Y%m') as start_month,count(start_time) as total_cnt,count(score) as complete_cnt,ROW_NUMBER() over(partition by uid order by DATE_FORMAT(start_time,'%Y%m') desc) as rk from t1 left join exam_record using(uid) group by 1,2) tmp where rk<=3 order by 1,2

全部评论

相关推荐

不愿透露姓名的神秘牛友
10-04 05:12
kalistar:简历留六个字,北京大学(本科),黑体加粗,看看哪个hr不长眼敢碰瓷我们北大✌
点赞 评论 收藏
分享
程序员牛肉:可以说含金量不如王者荣耀省标。
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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