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

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

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



select start_month,mau,month_add_uv
,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 
(
    select start_month
    ,count(distinct uid) as mau
    ,count(distinct case when start_month=first_month then uid else null end) as month_add_uv
    from 
    (
        select *
        ,date_format(start_time,"%Y%m") as start_month
        ,min(date_format(start_time,"%Y%m")) over(partition by uid order by date_format(start_time,"%Y%m")) as first_month
        from exam_record
    ) t 
    group by start_month
) t 
order by start_month




全部评论
sum(month_add_uv) over(order by start_month) as cum_sum_uv,我感觉这个求得是“截止当月的累计新增用户数”,而题目是“截止当月的累计用户数”,我理解的对么?
点赞 回复 分享
发布于 2022-04-19 14:37

相关推荐

11-15 18:39
已编辑
西安交通大学 Java
全村最靓的仔仔:卧槽,佬啥bg呢,本也是西交么
点赞 评论 收藏
分享
小红书 后端选手 n*16*1.18+签字费期权
点赞 评论 收藏
分享
40 2 评论
分享
牛客网
牛客企业服务