题解 | #每天的日活数及新用户占比#
每天的日活数及新用户占比
https://www.nowcoder.com/practice/dbbc9b03794a48f6b34f1131b1a903eb
#简单的判断思路解题,排序判断uid排名第一的登录的时间,再利用case进行判断 with tiaojian as ( select uid, date(in_time) as day from tb_user_log group by uid,day union all select uid, date(out_time) as day from tb_user_log group by uid,day ) select day, count(distinct uid) as dau, round( count(distinct case when m=1 then uid end)/count(distinct uid),2) as uv_new_ratio from( select uid, day, row_number()over(partition by uid order by day ) as m from tiaojian ) as t group by day order by day