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

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

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

with tmp as (
select 
    uid,
    exam_id,
    start_time,
    date_format(start_time,'%Y%m') as ym,
    row_number() over(partition by uid order by start_time) as rank1
from exam_record)

select 
    ym,
    count(distinct uid) as mau,
    sum(if(rank1=1, 1, 0)) as month_add_uv,
    max(sum(if(rank1=1, 1, 0)) ) over (order by ym) as max_month_add_uv,
    sum(sum(if(rank1=1, 1, 0))) over(order by ym) as cum_sum_uv
from tmp
group by ym
order by ym 
全部评论

相关推荐

牛客154160166号:9月底还给我发短信,好奇怪,我24届的
点赞 评论 收藏
分享
斑驳不同:还为啥暴躁 假的不骂你骂谁啊
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务