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

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

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

select
    t2.dt dt,
    count(t2.uid) as dau,
    round(count(t1.uid)/count(t2.uid), 2) uv_new_ratio
from
    (
        select
            uid,
            min(date (in_time)) dt
        from
            tb_user_log
        group by
            uid
    ) t1
    right join (
        select
            uid,
            date(in_time) dt
        from
            tb_user_log
        union 
        select
            uid,
            date(out_time)
        from
            tb_user_log
    ) t2
on t1.uid = t2.uid and t1.dt = t2.dt
group by
    t2.dt
order by
    t2.dt

全部评论

相关推荐

11-04 14:10
东南大学 Java
_可乐多加冰_:去市公司包卖卡的
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务