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

平均活跃天数和月活人数

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

select month,format(count(month)/count(distinct uid),2) avg_active_days,count(distinct uid) mau 
from 
(select date_format(t1.submit_time,'%Y%m') month,uid 
 from 
 (select distinct date_format(submit_time,'%Y%m%d') submit_time,uid 
  from exam_record 
  where submit_time is not null 
  and submit_time not like '2020%') t1 
  order by submit_time) t2 
  group by month;

解题思路:

一:先取出不同的提交日期

二:把日期的号去掉改成年月的格式

三:用统计的月份数量除以不同uid的用户数量

四:用年月的格式来排序

全部评论

相关推荐

点赞 评论 收藏
分享
09-12 11:55
已编辑
湖南工商大学 Java
那一天的Java_J...:这种一堆问题的,别去
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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