题解 | #近三个月未完成试卷数为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

全部评论

相关推荐

北枳的南橘:建议大家务必去和他沟通一下,像极了小学生对你侃侃而谈国际局势😂
找AI工作可以去哪些公司...
点赞 评论 收藏
分享
评论
点赞
1
分享

创作者周榜

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