题解 | #平均活跃天数和月活人数#

平均活跃天数和月活人数

http://www.nowcoder.com/practice/9e2fb674b58b4f60ac765b7a37dde1b9

#该题的重点在于计算不同用户月活天数的总和,会有天数重复,要用distinct函数划分时间。另外,注意是2021年数据
select date_format(start_time,"%Y%m") as month,
       round(count(distinct uid,date_format(start_time,"%Y%m%d"))/count(distinct uid),2) as avg_active_days, # 计算月活平均天数,
       count(distinct uid) as mau # 计算月活人数
from exam_record
where score is not null and year(start_time)=2021
group by month
全部评论
请问这个语句是什么意思呢 count(distinct uid,date_format(start_time,"%Y%m%d"))
3 回复 分享
发布于 2021-11-29 20:55
这个才是对的
1 回复 分享
发布于 2021-11-05 15:56
count出来两个数字可能是2,3,因为中间有个逗号,拿哪个除以分子,还是说count(distinct uid,date_format)出来的两个数字肯定一样的?
点赞 回复 分享
发布于 2022-03-23 10:38

相关推荐

不愿透露姓名的神秘牛友
07-04 18:02
好不容易拿到了字节Offer,鼠鼠做后端的,但家里人觉得可能被裁员不稳定,让鼠鼠去投国企,现在好纠结到底该咋选
文档传偷助手:该投就投吧,不过建议别放弃offer 拿到手里的才是最好的
投递字节跳动等公司8个岗位
点赞 评论 收藏
分享
06-12 10:50
门头沟学院 Java
你的不定积分没加C:我怎么在学院群看到了同样的话
点赞 评论 收藏
分享
06-07 17:17
嘉兴学院 教师
心爱的idea:你孩
点赞 评论 收藏
分享
评论
9
7
分享

创作者周榜

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