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

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

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
    

全部评论

相关推荐

点赞 评论 收藏
分享
12-15 14:16
门头沟学院 Java
回家当保安:发offer的时候会背调学信网,最好不要这样。 “27届 ”和“28届以下 ”公司招聘的预期是不一样的。
实习简历求拷打
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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