题解 | #每天的日活数及新用户占比#
每天的日活数及新用户占比
https://www.nowcoder.com/practice/dbbc9b03794a48f6b34f1131b1a903eb
select dt, count(distinct uid) as dau, round(sum(if(rk=1,1,0))/count(distinct uid),2) from( select uid, dt, rank() over (partition by uid order by dt asc) as rk from( select uid, date(in_time) as dt from tb_user_log union select uid, date(out_time) as dt from tb_user_log ) as t1) as t2 group by 1 order by dt asc