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

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

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 北京

相关推荐

05-19 19:57
蚌埠学院 Python
2237:Gpa70不算高,建议只写排名,个人技能不在多而在精,缩到8条以内。项目留一个含金量高的,减少间距弄到一页,硕士简历也就一页,本科不要写很多
实习,投递多份简历没人回...
点赞 评论 收藏
分享
_mos_:我以为手抄报简历就已经很顶了,没想到还有表格简历
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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