| createdate | unionid |
| 2021-11-03 10:00:00 | Th4ng7StzSaN4CVt2IoMxj6k |
-- 2. 再根据第一次访问日期分组, 然后去重, 就可以得到DNU了select first_date, count(distinct unionid) DNUfrom( -- 1. 先找到每个用户第一次访问日期select unionid, min(to_date(createdate)) first_datefrom table agroup by unionid) bgroup by first_date;
下一个我们来看一下日活、周活以及月活用户数如何计算?这三个的区别主要在于时间的范围不一样,日活主要以每日作为分组依据,周活以周作为分组依据,月活就是以月作为分组依据。
select to_date(partition_date) createdate, count(distinct unionid) DAUfrom table agroup by to_date(partition_date);
select date_range, week, count(distinct unionid) WAUFROM(select to_date(createdate) createdate, weekofyear(to_date(createdate)) week,concat_ws('__',min(to_date(createdate)) over(partition by weekofyear(to_date(createdate))),max(to_date(createdate)) over(partition by weekofyear(to_date(createdate)))) date_range,unionidfrom table a) bgroup by week, date_range;
select DATE_FORMAT(to_date(partition_date),"yyyy-MM") ym_date, count(distinct unionid) MAUFROM tablegroup by DATE_FORMAT(to_date(partition_date),"yyyy-MM");
参考文章:
DAU,WAU,MAU分析活跃以及留存用户
http://www.jiangwenseo.com/operating/825.html
用户活跃、留存、流失,终于讲清楚了!
https://cloud.tencent.com/developer/news/645667
画说日活、新增、留存、回流及其关系模型
https://www.jianshu.com/p/3018da7b29cb
什么是新增用户、活跃用户、留存用户?
https://cloud.tencent.com/developer/article/1513585
文章转载自数分小白龙,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




