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

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

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 
全部评论

相关推荐

11-15 17:19
湖南大学 Java
成果成果成果果:这是哪个公司的hr,这么离谱吗,我没见过用性别卡技术岗的,身边女性同学拿大厂offer的比比皆是
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务