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

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

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

with user_dau
as(
    select 
    uid,
    date(in_time) as dt
    from tb_user_log

    union 

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

user_sign 
as(
    select
    uid,
    date(min(in_time)) as first_time
    from tb_user_log
    group by 1
)

select
dt as dt,
count(distinct dau.uid) as dau,
round(sum(if(dt = first_time, 1, 0))/count(distinct dau.uid), 2)
from user_dau dau
left join user_sign sign 
on dau.uid = sign.uid
group by 1
order by 1

全部评论

相关推荐

01-21 20:09
武汉大学 Java
点赞 评论 收藏
分享
递归到脑子变傻:杭州还有上位机用VB的,实在没绷住
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务