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

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

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

select start_month,count(distinct uid) as mau,
sum(new_day) as month_add_uv,
max(sum(new_day)) over(order by start_month) as max_month_add_uv,
sum(sum(new_day)) over(order by start_month) as cum_sum_uv
from(
select *,date_format(start_time,'%Y%m') as start_month,
if(start_time = min(start_time)over(partition by uid),1,0) as new_day from exam_record) as t1
group by start_month

先统计一下每个月新出现的人数new_day,然后使用窗口函数进行统计,

全部评论

相关推荐

半解316:内容充实,细节需要修改一下。 1,整体压缩为一页。所有内容顶格。 2,项目描述删除,直接写个人工作量 修改完之后还需要建议,可以私聊
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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