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

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

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

select dt,dau,ifnull(round(ct/dau,2),0.00) as uv_new_ratio from

(select first_dt,count(uid) as ct from
	(select uid,min(date(in_time)) first_dt from tb_user_log group by uid) a 
	group by first_dt
) a1
right join
(select dt,ifnull(count(distinct uid),0) as dau from(
    select uid,date(in_time) dt from tb_user_log
    union
    select uid,date(out_time) dt from tb_user_log
) b group by b.dt
) b1
on a1.first_dt=b1.dt

全部评论

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务