题解 | #每天的日活数及新用户占比#
每天的日活数及新用户占比
https://www.nowcoder.com/practice/dbbc9b03794a48f6b34f1131b1a903eb
select date(in_time) as dt ,count(distinct t1.uid) as dau, round(count(distinct t.uid)/count(distinct t1.uid),2) as uv_new_ratio from (select uid,in_time from tb_user_log union select uid,out_time from tb_user_log)t1 left join (select uid,min(date(in_time)) as dt from tb_user_log group by uid) t on t.uid=t1.uid and t.dt=date(in_time) group by date(in_time) order by dt
长期出错的两个点
审题不严
1、活跃没有看到 in_time 和 out time 都算在里面
2、表链接使用了join ,这里肯定是使用left join
这个题并不难,就是爱出小错误。