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

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

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 


记录一下

全部评论

相关推荐

头像
11-09 17:30
门头沟学院 Java
TYUT太摆金星:我也是,好几个华为的社招找我了
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务