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

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

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

select 
    t1.active   dt
    ,a         dau
    ,ifnull(round(b/a,2),0)  nv_new_ratio
from 

(
select 
    date(active) active 
    ,count(distinct uid) a
from 
    (select 
        uid
        ,in_time active
    from 
        tb_user_log
    union 
    select 
        uid
        ,out_time active
    from 
        tb_user_log) t
group by 
    date(active) 
) t1
left join 
(
select 
    min_date
    ,count(uid) b
from
(
select 
    uid 
    ,min(date(in_time)) min_date
from 
    tb_user_log 
group by 
    uid
) t0
group by 
    min_date
order by 
    min_date
) t2
on t1.active=t2.min_date

全部评论

相关推荐

废铁汽车人:秋招真是牛鬼蛇神齐聚一堂
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
11-27 10:46
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务