题解 | #每月及截止当月的答题情况#

每月及截止当月的答题情况

https://www.nowcoder.com/practice/1ce93d5cec5c4243930fc5e8efaaca1e

#3.计算截止当月的单月最大新增用户数、截止当月的累积用户数
select 
    *,
    max(month_add_uv) over (order by start_month) as   max_month_add_uv,
    sum(month_add_uv) over (order by start_month) as cum_sum_uv
from(
    #2.计算每月活跃用户数和每月新增用户数
    select 
        start_month,
        count(distinct uid) as mau,
        sum(new_user) as month_add_uv
    from(
        #1.首先判断用户是否为新增用户
        select 
            uid,
            date_format(start_time,'%Y%m') as start_month,
            if(start_time = min(start_time) over (partition by uid),1,0) as new_user
        from
            exam_record)as a
    group by start_month)as b
    order by start_month

踩坑点:第一步就要判断是否为新用户

全部评论

相关推荐

求面试求offer啊啊啊啊:把华北改为华南再试一试,应该就没啥问题了。改完可能都不用投,别人主动联系了。
点赞 评论 收藏
分享
04-25 18:13
五邑大学 Java
后来123321:大二两段实习太厉害了,我现在大二连面试都没有
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务