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

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

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

-- 判断新老户
with is_new as(
    select
    uid
    ,date(min(in_time)) as dt
    from tb_user_log
    group by uid
)
, record as(
    select uid,date(in_time) as dt
    from tb_user_log

    UNION

    select uid,date(out_time) as dt
    from tb_user_log
)

select
a.dt 
,count(a.uid) as dau
,round(count(b.uid)/count(a.uid),2) as uv_new_ratio
from record a 
left join is_new b 
on a.uid=b.uid
and a.dt=b.dt
group by a.dt
order by a.dt



全部评论

相关推荐

牛客410815733号:这是什么电影查看图片
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务