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

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

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

select a.start_month,count(distinct uid) as mau,
count(distinct if(first_month=start_month,uid,null)) as month_add_uv,
max(count(distinct if(first_month=start_month,uid,null))) over(order by start_month) max_month_add_uv,
sum(count(distinct if(first_month=start_month,uid,null))) over(order by start_month)  cum_sum_uv
from(
  SELECT uid,
           min(date_format(start_time,"%Y%m")) over(partition by uid order by date_format(start_time,"%Y%m")) as first_month, 
        date_format(start_time,'%Y%m') as start_month
from exam_record
)a
group by a.start_month
    

全部评论

相关推荐

S_Holmes:一想到我苦苦追求的迪子私下里却是985的马子,我的心就在滴血😭😭😭
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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