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

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

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

select
utime dt, count(*) dau, round(sum(new_user)/count(*),2) uv_new_ratio
from(
    select
    b.uid, b.utime, if(a.firstday = b.utime, 1, 0) new_user
    from(
        select uid, date(min(in_time)) firstday
        from tb_user_log
        group by uid
    ) a left join(
        select uid, date(in_time) utime from tb_user_log
        union
        select uid, date(out_time) utime from tb_user_log
    ) b 
    on a.uid = b.uid 
) t
group by utime 
order by utime 


记录一下

全部评论

相关推荐

冲芭芭拉鸭:你这图还挺新,偷了。
投递美团等公司10个岗位
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务