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

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

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

# 自从有用户作答记录以来,每月的试卷作答记录中月活用户数、新增用户数、截止当月的单月最大新增用户数、截止当月的累积用户数
# 月活用户数
with A as (
select date_format(start_time,'%Y%m')start_month
,count(distinct uid)mau
from exam_record
group by 1
)
# 新增用户数 找他的最小月份 再以月份分组 count一下
,B as (
select start_month,count(uid)month_add_uv from
(select uid,min(date_format(start_time,'%Y%m'))start_month
from exam_record
group by 1)b
group by 1
)
# 截止当月的单月最大新增用户数 开个窗完事 连表的时候再写 要不然会少数据
# 截止当月的累积用户数 新增+新增 同上 开个窗完事
,C as 
(select start_month,max(c)over(order by start_month)cum_sum_uv
from 
(select date_format(start_time,'%Y%m')start_month,count(distinct uid)c
from exam_record
group by 1 
order by 1)c)
# 连表去空
select start_month,mau
,ifnull(month_add_uv,0)month_add_uv
,max_month_add_uv,cum_sum_uv
from
(select start_month,mau,month_add_uv
,max(month_add_uv)over(order by start_month)max_month_add_uv
,sum(month_add_uv)over(order by start_month)cum_sum_uv
from A
left join B using(start_month)
left join C using(start_month))z
order by 1

全部评论

相关推荐

嵌入式的小白:面试少的,说明你的投递的岗位和简历匹配度不高,技术这个东西很杂的,你这种情况,建议 1.看看嵌入式招聘的岗位需求,会有不同大方向的,比如MCU,RTOS的,或者linux上驱动的,或者应用层的,这都是简单分类,但对技术要求差异很大的 2.结合你的经验,看能和哪类匹配上,就找对应类别的 3.简历和招聘岗位需求对着看下,看人家需要啥,你会啥,匹配度高才有会高概率有面试的
秋招的第一个offer,...
点赞 评论 收藏
分享
2025-12-22 16:31
已编辑
桂林电子科技大学 Python
很奥的前端仔:如果你接了offer 临时又说不去 hr确实要多做一些工作。 当然如果是接offer之前当我没说
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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