题解 | #每天的日活数及新用户占比#
每天的日活数及新用户占比
https://www.nowcoder.com/practice/dbbc9b03794a48f6b34f1131b1a903eb
select t1.dt, t1.dau,
round(count(t2.uid) / t1.dau, 2) as uv_new_ratio
from (
select a.dt, count(a.uid) as dau
from
(
select uid, date(in_time) as dt
from tb_user_log
union
select uid, date(out_time) as dt
from tb_user_log
) a
group by a.dt
order by a.dt asc
) t1
left join (
select uid, min(date(in_time)) as dt
from tb_user_log
group by uid
) t2
on t1.dt = t2.dt
group by t1.dt
order by t1.dt
腾讯成长空间 6074人发布