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

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

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

相关推荐

见见123:简历没有啥问题,是这个社会有问题。因为你刚毕业,没有工作经历,现在企业都不要没有工作经历的。社会病了。
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
07-02 18:35
简历上把1个月实习写成了3个月,会进行背调吗?
码农索隆:一个月有一个月的实习经历,三个月有三个月的实习经历
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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