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

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

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

select 
t1.*,coalesce(t2.month_add_uv,0) month_add_uv,
max(month_add_uv)over(order by t1.start_month) max_month_add_uv,
sum(month_add_uv)over(order by t1.start_month) cum_sum_uv

 from

(
select
date_format(start_time,'%Y%m') start_month,
count(distinct uid)  mau
from exam_record 
group by start_month
)t1

left join
(
    select
start_month,
count(uid) month_add_uv
# count(uid)over(partition by start_month order by start_month)
from
(
select
uid,
date_format(start_time,'%Y%m') start_month,
row_number()over(partition by uid order by date_format(start_time,'%Y%m')) rn
from exam_record 
)t
where rn=1
group by start_month
) t2
using(start_month)



#MySQL#
全部评论
盐咸咸的真的很赞
点赞 回复 分享
发布于 2022-09-26 11:28 北京

相关推荐

06-26 22:20
门头沟学院 Java
码农索隆:让你把简历发给她,她说一些套话,然后让你加一个人,说这个人给你改简历,然后开始卖课
我的求职精神状态
点赞 评论 收藏
分享
06-10 21:15
门头沟学院 Java
宁阿:好多这种没🧠的公司,他们估计都不知道毕业的人不能给安排实习岗
实习吐槽大会
点赞 评论 收藏
分享
我是没经验的毕业生,这啥情况啊会不会是hr在刷kpi
JamesGosli...:字节boss属于是群发了,我都快入职字节了,其他部门还在和我boss打招呼
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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