题解 | #近三个月未完成试卷数为0的用户完成情况#

近三个月未完成试卷数为0的用户完成情况

https://www.nowcoder.com/practice/4a3acb02b34a4ecf9045cefbc05453fa

with table1 as (
    select uid , 
    date_format(start_time,'%Y%m') as time,
    submit_time,
    dense_rank() over(partition by uid order by date_format(start_time,'%Y%m') desc) as time_rank
    from exam_record
),
table2 as (
    select uid ,
    sum(if(time is not null , 1 , 0)) as exam_all_cnt,
    sum(if(submit_time is not null , 1 , 0)) as exam_complete_cnt
    from table1 
    where time_rank <= 3
    group by uid
    having exam_complete_cnt = exam_all_cnt
)

select uid , exam_complete_cnt
from table2
order by exam_complete_cnt desc ,uid desc

全部评论

相关推荐

2025-12-04 15:36
门头沟学院 Java
点赞 评论 收藏
分享
之前自己不懂事,投了字节,基本是自己第一次面试,一面就挂了
观水:前几天有个学化学的做前端,加上实习面了22次字节最后成功了
点赞 评论 收藏
分享
评论
点赞
1
分享

创作者周榜

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