题解 | #每天的日活数及新用户占比#

每天的日活数及新用户占比

https://www.nowcoder.com/practice/dbbc9b03794a48f6b34f1131b1a903eb


select dt ,count(distinct uid) as dau , round(sum(if(rank_dt = 1,1,0)) / count(distinct uid),2) as uv_new_ratio 
from (
select uid ,dt ,rank() over(partition by uid order by dt) as rank_dt 
from (
-- 获取用户信息总表
select uid , date(in_time) as dt 
from tb_user_log 
union 
select uid , date(out_time) as dt 
from tb_user_log ) t1 ) t2 
group by dt 
order by dt 

全部评论

相关推荐

投递腾讯等公司8个岗位
点赞 评论 收藏
转发
点赞 收藏 评论
分享
牛客网
牛客企业服务